Module:Unsubst-infobox explained

local p =

local specialParams =

p[''] = function (frame) if not frame:getParent then error(' makes no sense without a parent frame') end if not frame.args['$B'] then error(' requires parameter $B (template content)') end if not frame.args['$params'] then error(' requires parameter $params (parameter list)') end

if mw.isSubsting then ---- substing -- Combine passed args with passed defaults local args = if string.find(','..(frame.args['$flags'] or )..',', ',%s*override%s*,') then for k, v in pairs(frame:getParent.args) do args[k] = v end for k, v in pairs(frame.args) do if not specialParams[k] then if v

'__DATE__' then v = mw.getContentLanguage:formatDate('F Y') end args[k] = v end end else for k, v in pairs(frame.args) do if not specialParams[k] then if v

'__DATE__' then v = mw.getContentLanguage:formatDate('F Y') end args[k] = v end end for k, v in pairs(frame:getParent.args) do args[k] = v end end

-- 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

if frame.args['$template-name'] and ~= frame.args['$template-name'] then title = frame.args['$template-name'] -- override whatever the template name is with this name end

-- Remove empty fields for k, v in pairs(args) do if v

then args[k] = nil end end

-- Pull information from parameter aliases local aliases, extra =, if frame.args['$aliases'] then local list = mw.text.split(frame.args['$aliases'], '%s*,%s*') for k, v in ipairs(list) do local tmp = mw.text.split(v, '%s*>%s*') local alias = (tonumber(mw.ustring.match(tmp[1], '^[1-9][0-9]*$'))) or tmp[1] aliases[alias] = ((tonumber(mw.ustring.match(tmp[2], '^[1-9][0-9]*$'))) or tmp[2]) extra[alias] = true end end for k, v in pairs(aliases) do if args[k] and not args[v] then args[v], args[k] = args[k], nil end end

-- Build the invocation body with numbered args first, then named local ret = ''

ret = mw.ustring.gsub(ret, '%s+\n', '\n')

return ret else -- Not substing -- Just return the "body" return frame.args['$B'] endend

return p