Module:Uses TemplateStyles
Documentation for this module may be created at Module:Uses TemplateStyles/doc
-- This module implements the {{Uses TemplateStyles}} template.
local mMessageBox = require('Module:Message box')
local p = {}
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
function p._main(args)
return p.renderBox(args)
end
function p.renderBox(tStyles)
local boxArgs = {}
if #tStyles < 1 then
boxArgs.text = '<strong class="error">Error: no TemplateStyles specified</strong>'
else
local tStylesLinks = {}
for i, ts in ipairs(tStyles) do
local sandboxLink = nil
local tsTitle = mw.title.new(ts)
if tsTitle then
local tsSandboxTitle = mw.title.new(string.format('%s:%s/sandbox/%s', tsTitle.nsText, tsTitle.baseText, tsTitle.subpageText))
if tsSandboxTitle and tsSandboxTitle.exists then
sandboxLink = string.format(' ([[:%s|sandbox]])', tsSandboxTitle.prefixedText)
end
end
tStylesLinks[i] = string.format('[[:%s]]%s', ts, sandboxLink or '')
end
local tStylesList = mw.text.listToText(tStylesLinks)
boxArgs.text = 'This ' ..
(mw.title.getCurrentTitle():inNamespaces(828,829) and 'module' or 'template') ..
' uses [[mw:Extension:TemplateStyles|TemplateStyles]]:\n' .. tStylesList
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[File:Farm-Fresh css add.svg|32px|alt=CSS]]'
return mMessageBox.main('mbox', boxArgs)
end
return p