Módulo:Toolbar
This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
Descrição
Este Módulo tem funções auxiliares de {{Toolbar}}
Uso
Outra documentação:
-- This module implements {{toolbar}}.
local mArguments -- Lazily initialise [[Module:Arguments]]
local mTableTools = require('Módulo:TableTools')
local yesno = require('Módulo:Yesno')
local p = {}
function p.main(frame)
mArguments = require('Módulo:Arguments')
local args = mArguments.getArgs(frame)
return p._main(args)
end
function p._main(args)
local toolbarItems = p.makeToolbarItems(args)
if not toolbarItems then
-- Return the blank string if no arguments were specified, rather than
-- returning empty brackets.
return ''
elseif yesno(args.span) == false then
return string.format(
'(%s)',
toolbarItems
)
else
return string.format(
'<span class="plainlinks%s"%s>(%s)</span>',
type(args.class) == 'string' and ' ' .. args.class or type(args.classe) == 'string' and ' ' .. args.classe or '',
type(args.style) == 'string' and string.format(' style="%s"', args.style) or type(args.estilo) == 'string' and string.format(' style="%s"', args.estilo) or '',
toolbarItems
)
end
end
function p.makeToolbarItems(args)
local nums = mTableTools.numKeys(args)
local sep = (args.separator or args.separador or 'pipe') .. '-separator'
sep = mw.message.new(sep):plain()
local ret = {}
for i, v in ipairs(nums) do
ret[#ret + 1] = mw.ustring.gsub(args[v], "%[%[::+(.-)%]%]", "[[:%1]]")
end
if #ret > 0 then
return table.concat(ret, sep)
else
return nil
end
end
return p