Módulo:C.Skin
Ir para navegação
Ir para pesquisar
A documentação para este módulo pode ser criada em Módulo:C.Skin/doc
-- Módulo:C.Skin — função skin()
local p = {}
local utils = require("Módulo:C.Utils")
local normalizeDim = utils.normalizeDim
--------------------------------------------------------------------------------
-- Serializer de skin (para {{Skin}})
--------------------------------------------------------------------------------
function p.skin(frame)
local a = frame.args
local function nz(s)
s = mw.text.trim(tostring(s or ""))
return (s ~= "" and s or nil)
end
-- i18n para tooltip (mantém legado)
local pack = {
pt = nz(a.tooltip_pt),
en = nz(a.tooltip_en),
es = nz(a.tooltip_es),
pl = nz(a.tooltip_pl)
}
local tooltip
if pack.pt or pack.en or pack.es or pack.pl then
tooltip = mw.text.jsonEncode(pack)
else
tooltip = a.tooltip or ''
end
local obj = {
sprite = a.sprite or '',
tooltip = tooltip,
youtube = a.youtube or '',
source = a.source or '',
name = a.name or a.nome or '',
w = normalizeDim(a.w or a.width),
h = normalizeDim(a.h or a.height),
tile = a.tile or '',
tile_x = a.tile_x or '',
tile_y = a.tile_y or '',
offset_x = a.offset_x or ''
}
return mw.text.jsonEncode(obj)
end
return p