Jump to content

Module:Unsubst: Difference between revisions

add tracking category per protected edit request by User:Jackmcbarn
No edit summary
(add tracking category per protected edit request by User:Jackmcbarn)
Line 1:
local p = {}
 
local specialParams = {
['$N'] = 'template name', -- Deprecated, but keeping until it is removed from transcluding templates
['$B'] = 'template content',
}
 
p[''] = function ( frame )
if not frame:getParent() then
Line 13:
error( '{{#invoke:Unsubst|}} requires parameter $B (template content)' )
end
if mw.isSubsting() then
---- substing
Line 29:
args[k] = v
end
 
-- Build an equivalent template invocation
-- First, find the title to use
Line 41:
title = titleobj.prefixedText
end
 
-- Build the invocation body with numbered args first, then named
local ret = '{{' .. title
Line 55:
ret = ret .. '|' .. k .. '=' .. v
end
return ret .. '}}'
else
---- Not substing
-- Just return the "body"
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 '')
return frame.args['$B']
end
end
 
return p
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.