Module:Citation/CS1/Configuration: Difference between revisions

Guard against getContent() returning nil (e.g. previewing a new citation against a new article in VE)
(sync from sandbox;)
(Guard against getContent() returning nil (e.g. previewing a new citation against a new article in VE))
Line 454: Line 454:


local function get_date_format ()
local function get_date_format ()
local content = mw.title.getCurrentTitle():getContent(); -- get the content of the article
local content = mw.title.getCurrentTitle():getContent() or ''; -- get the content of the article
for _, pattern in ipairs (df_template_patterns) do -- loop through the patterns looking for {{Use dmy dates}} or {{Use mdy dates}} or any of their redirects
for _, pattern in ipairs (df_template_patterns) do -- loop through the patterns looking for {{Use dmy dates}} or {{Use mdy dates}} or any of their redirects
local start, _, match = content:find(pattern); -- match is the three letters indicating desired date format
local start, _, match = content:find(pattern); -- match is the three letters indicating desired date format