Module:Template wrapper

require('Module:No globals');

local p={};

local function isInTable(tbl, item) for key, value in pairs(tbl) do       if value == item then return true end end return false end

function p.wraps (frame) local args = {}; local template; local blacklist; for k, v in pairs (frame.args) do											-- here we get the wrapper template's 'default' parameters if '_template' == k then template = v;														-- save the name of template that we are wrapping elseif '_blacklist' == k then blacklist = mw.text.split(v, "%s*,%s*");							-- save the blacklisted parameters else args[k] = v;														-- copy frame parameters to args table end end if nil == template or '' == template then									-- this is the one parameter required by this module return ' missing or empty '; end

local pframe = frame:getParent;											-- here we get the wrapper template's 'live' parameters for k, v in pairs (pframe.args) do		if 'string' == type (k) and not not k:find ('^_') and not isInTable(blacklist, v) then	-- do not pass along positional or blacklisted parameters if v and v ~= '' then												-- pass along only those parameters that have assigned values if 'unset' == v:lower then									-- special keyword to unset 'default' parameters set in the wrapper template v = '';														-- unset the value end args[k] = v;													-- copy parent frame parameters to args table end end end return frame:expandTemplate {title=template, args=args};					-- render the template end

return p;