Module:Template

local template = {}

function template.page(frame) local args, pargs = frame.args, frame:getParent.args local subst, title = mw.ustring.match( args[1] or pargs[1] or '', '^%s*(subst):(.+)$' ) -- get title whether pagename, subst:pagename, or safesubst:pagename if not subst then subst, title = mw.ustring.match( args[1] or pargs[1] or '', '^%s*(safesubst):(.+)$' ) title = title or args[1] or pargs[1] or '' end local success, page = pcall(function(title) return mw.title.new( title, 10 ) end, title or '' ) if not success or not page then return '' end if page.interwiki ~= "" then title = title:sub( page.interwiki:len+2 ) end if page.fragment ~= "" then title = title:sub( 1, -page.fragment:len-2 ) end return ( subst and  .. subst .. ':' or  ) ..  .. title ..  end

function template.example(frame) local args, result = frame.args[1] and frame.args or frame:getParent.args, template.page(frame) if result == '' then return '' end for name, value in pairs( args ) do       if type( name ) == 'number' then if name ~= 1 then result = result .. '|' .. value .. '' end else result = result .. '|' .. name .. '=' .. value .. '' end end return '' end

return template