Open main menu

Changes

Module:Unsubst

341 bytes added, 01:52, 30 March 2014
Deprecate the $N parameter; the template name is now detected automatically. The $N check is still present until all transclusions have been updated. Code courtesy of User:Anomie, User:Jackmcbarn and myself.
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
error( '{{#invoke:Unsubst|unsubst}} makes no sense without a parent frame' )
end
for k, v in pairs( specialParams ) do if not frame.args[k'$B'] then error( '{{#invoke:Unsubst|unsubst}} requires parameter ' .. k .. ' $B (' .. v .. 'template content)' ) end
end
end
-- Now, build Build an equivalent template invocation -- First , find the title to use local titleobj = mw.title.new(frame:getParent():getTitle()) local title if titleobj.namespace == 10 then -- NS_TEMPLATE title = titleobj.text elseif titleobj.namespace == 0 then -- NS_MAIN title = ':' .. titleobj.text else title = titleobj.prefixedText end  -- Build the invocation body with numbered argsfirst, then named local ret = '{{' .. frame.args['$N']title
for k, v in ipairs( args ) do
if string.find( v, '=', 1, true ) then
Anonymous user