Module:Template view
Appearance
Documentation for this module may be created at Module:Template view/doc
local p = {}
local getArgs
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame, {wrappers = 'Template:V', 'Template:View'})
local t_name = args.template or args[1]
-- Calling URL parameters in fullurl: forces the url to be of the form index.php?title=, which is prefered
-- We'll call ?action= here to force that, and pass an argument within switches[]
local t_url = frame:preprocess('{{fullurl:Template:'..t_name..'|action=}}')
local r_string = '<span class="noprint plainlinks navbar" style="white-space:nowrap;word-spacing:-.12em;">'
local switches = {
['t'] = ' <b>·</b> [[Template talk:'..t_name..
'|<span style="font-variant:small-caps;color:#002bb8;" title="Discuss this template">t</span>]]',
['talk'] = ' <b>·</b> [[Template talk:'..t_name..
'|<span style="color:#002bb8;" title="Discuss this template">talk</span>]]',
['h'] = ' <b>·</b> ['..t_url..
'history <span style="font-variant:small-caps;color:#002bb8;" title="Template history">h</span>]',
['hist'] = ' <b>·</b> ['..t_url..
'history <span style="color:#002bb8;" title="Template history">hist</span>]',
['e'] = ' <b>·</b> ['..t_url..
'edit <span style="font-variant:small-caps;color:#002bb8;" title="Edit this template">e</span>]',
['edit'] = ' <b>·</b> ['..t_url..
'edit <span style="color:#002bb8;" title="Edit this template">edit</span>]',
['m'] = ' <b>·</b> ['..frame:preprocess('{{fullurl:Special:MovePage|target=Template:'..t_name..'}}')..
'<span style="font-variant:small-caps;color:#002bb8;" title="Move this template">m</span>]',
['move'] = ' <b>·</b> ['..frame:preprocess('{{fullurl:Special:MovePage|target=Template:'..t_name..'}}')..
'<span style="color:#002bb8;" title="Move this template">move</span>]',
['w'] = ' <b>·</b> ['..t_url..
'watch <span style="font-variant:small-caps;color:#002bb8;" title="Watch this template">w</span>]',
['watch'] = ' <b>·</b> ['..t_url..
'watch <span style="color:#002bb8;" title="Watch this template">watch</span>]',
}
switches['d'] = switches['t']
if args.view and args.view:find('%S') then
r_string = r_string..'[[Template:'..t_name..'|<span title="View this template">view</span>]]'
else
r_string = r_string..'[[Template:'..t_name..'|<span style="font-variant:small-caps;" title="View this template">v</span>]]'
end
for _,v in ipairs(args) do
if switches[v:lower()] then
r_string = r_string..switches[v:lower()]
end
end
r_string = r_string..'</span>'
return r_string
end
return p