Content deleted Content added
KnightLago (talk | contribs) m Protected "Module:Template invocation": Highly visible template ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) |
Update name call to fix a few edge cases per request |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 20:
if type(title) == 'string' then
title = mw.title.new(title)
if not title or #title.prefixedText == 0 or #title.interwiki > 0 then
error("invalid title in parameter #1 of function 'name'", 2)
end
Line 27:
end
if title.namespace == 10 then
local check = mw.title.new(text, 10)
-- Exclude the prefix, unless we have something like "Template:Category:Foo", which can't be abbreviated to "Category:Foo".
return check and mw.title.equals(title, check) and text or title.prefixedText
elseif title.namespace == 0 then
return ':' .. title.prefixedText
Line 34 ⟶ 37:
end
end
------------------------------------------------------------------------
-- Name: p.invocation
Line 94 ⟶ 96:
for k, v in ipairs(invArgs) do
if type(v) == 'string' and v:find('=', 1, true) then
-- Likely something like 1=foo=bar
ret[#ret + 1] = seps.pipe▼
ret[#ret + 1] = v▼
invArgs[k] = nil -- Erase the key so that we don't add the value twice▼
end
▲ ret[#ret + 1] = seps.pipe
▲ ret[#ret + 1] = v
▲ invArgs[k] = nil -- Erase the key so that we don't add the value twice
end
local
for k,
end
table.sort(
function (a, b)
for i, v in ipairs(invArgs_list) do -- Add named args based on sorted parameter list▼
-- Sort with keys of type number first, then string.
ret[#ret + 1] = seps.pipe▼
if type(a) == type(b) then
ret[#ret + 1] = v▼
return a < b
elseif type(a) == 'number' then
return true
end
end
)
local maybeSpace = '' -- First named parameter should not be separated by a space
▲ ret[#ret + 1] = maybeSpace .. seps.pipe
▲ ret[#ret + 1] = tostring(v)
ret[#ret + 1] = seps.equals
ret[#ret + 1] = invArgs[v]
maybeSpace = ' '
end
ret[#ret + 1] = seps.closeb
|