Content deleted Content added
more logging |
Despite this comment, both functions handle the case of the template identically |
||
Line 374:
end
--[[--------------------------< T E M P L A T E _ N A M E _
if passed a module invocation, return the name of the template represented. Otherwise return the input.
▲--[[--------------------------< T E M P L A T E _ N A M E _ G E T >--------------------------------------------
{{#invoke:cite|foo|...}} or {{#invoke:cite bar||...}} will return "cite foo" and "cite bar", respectively.
return the citation or harvc template's name; convert to lower case and trim leading and trailing whitespace;▼
when the template is a sandbox the subpage portion of the template name is omitted from the returned template name▼
{{Cite book/new |...}} returns cite book▼
]]
local function
local template_name = template:match ('^{{%s*([^/|}]+)'); -- get template name; ignore subpages ~/new, ~/sandbox; parser functions▼
if template_name and template_name:match ('^#invoke%s*:') then -- handle directly-invoked citation modules
template_name = template_name:match ('^#invoke%s*:%s*(.+)'); -- get module name
Line 393 ⟶ 389:
mw.logObject(func_name,"func_name")
if template_name and func_name then -- valid module invocation
template_name = nil; -- could not get module and function name▼
end;
end;
return template_name
end
--[[--------------------------< T E M P L A T E _ N A M E _ G E T >--------------------------------------------
▲return the citation or harvc template's name; convert to lower case and trim leading and trailing whitespace;
▲when the template is a sandbox the subpage portion of the template name is omitted from the returned template name
▲ {{Cite book/new |...}} returns cite book
]]
local function template_name_get (template)
▲ local template_name = template:match ('^{{%s*([^/|}]+)'); -- get template name; ignore subpages ~/new, ~/sandbox; parser functions
template_name = template_name_from_module (template, template_name); -- if passed a module invocation, return the name of the template represented
if not template_name or template_name:match ('^#') then -- parser functions, magic words don't count as templates
return nil; -- could not get template name from (possibly corrupt) template; extraneous opening { mid template can cause this;
Line 712 ⟶ 723:
local function template_list_add (template, template_list)
local template =
list_add (template, template_list); -- add to list with (unused) tally
end
|