Module:Unsubst: Difference between revisions
Content added Content deleted
No edit summary |
m (all uses removed) |
||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
local specialParams = { |
local specialParams = { |
||
['$N'] = 'template name', -- Deprecated, but keeping until it is removed from transcluding templates |
|||
['$B'] = 'template content', |
['$B'] = 'template content', |
||
} |
} |
||
p[''] = function ( frame ) |
p[''] = function ( frame ) |
||
if not frame:getParent() then |
if not frame:getParent() then |
||
Line 13: | Line 12: | ||
error( '{{#invoke:Unsubst|}} requires parameter $B (template content)' ) |
error( '{{#invoke:Unsubst|}} requires parameter $B (template content)' ) |
||
end |
end |
||
if mw.isSubsting() then |
if mw.isSubsting() then |
||
---- substing |
---- substing |
||
Line 29: | Line 28: | ||
args[k] = v |
args[k] = v |
||
end |
end |
||
-- Build an equivalent template invocation |
-- Build an equivalent template invocation |
||
-- First, find the title to use |
-- First, find the title to use |
||
Line 41: | Line 40: | ||
title = titleobj.prefixedText |
title = titleobj.prefixedText |
||
end |
end |
||
-- Build the invocation body with numbered args first, then named |
-- Build the invocation body with numbered args first, then named |
||
local ret = '{{' .. title |
local ret = '{{' .. title |
||
Line 55: | Line 54: | ||
ret = ret .. '|' .. k .. '=' .. v |
ret = ret .. '|' .. k .. '=' .. v |
||
end |
end |
||
return ret .. '}}' |
return ret .. '}}' |
||
else |
else |
||
---- Not substing |
---- Not substing |
||
-- Just return the "body" |
-- Just return the "body" |
||
return frame.args['$B'] |
|||
return frame.args['$B'] .. (frame.args['$N'] and frame:getParent():getTitle() == mw.title.getCurrentTitle().prefixedText and '[[Category:Calls to Module:Unsubst that use $N]]' or '') |
|||
end |
end |
||
end |
end |
||
return p |
return p |