Tim (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
K (10 Versionen importiert) |
||
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 15: | Zeile 15: | ||
root:tag('div') | root:tag('div') | ||
:addClass('infobox-image') | :addClass('infobox-image') | ||
:wikitext(string.format('[[Datei:%s|center| | :wikitext(string.format('[[Datei:%s|center|%s|%s]]', args['image'], args['image-width'] or '280px',args['image-alt'] or '')) | ||
end | end | ||
if args['subtitle'] then | if args['subtitle'] then | ||
Zeile 26: | Zeile 26: | ||
local label = args['label' .. i] | local label = args['label' .. i] | ||
local data = args['data' .. i] | local data = args['data' .. i] | ||
root:tag('div') | -- Skip the row if label or data is "", "Meter", "Kilogramm", or "[[]]" | ||
if label and data and label ~= "" and data ~= "" and | |||
label ~= "Meter" and data ~= "Meter" and | |||
label ~= "Kilogramm" and data ~= "Kilogramm" and | |||
label ~= "Liter" and data ~= "Liter" and | |||
label ~= "[[]]" and data ~= "[[]]" then | |||
root:tag('div') | |||
:addClass('infobox-row') | |||
:tag('div') | |||
:addClass('infobox-label') | |||
:wikitext(label) | |||
:done() | |||
:tag('div') | |||
:addClass('infobox-data') | |||
:wikitext(data) | |||
:done() | |||
end | |||
end | end | ||
Aktuelle Version vom 18. August 2024, 10:30 Uhr
Modul zur Erstellung von Infoboxen, Siehe Vorlage:Infobox für mehr Informationen
local p = {}
local function infoboxTemplate(frame)
local args = frame:getParent().args
local root = mw.html.create('div')
:addClass('infobox')
:css('width', '22em')
if args['title'] then
root:tag('div')
:addClass('infobox-title')
:wikitext(args['title'])
end
if args['image'] then
root:tag('div')
:addClass('infobox-image')
:wikitext(string.format('[[Datei:%s|center|%s|%s]]', args['image'], args['image-width'] or '280px',args['image-alt'] or ''))
end
if args['subtitle'] then
root:tag('div')
:addClass('infobox-subtitle')
:wikitext(args['subtitle'])
end
for i = 1, 50 do
local label = args['label' .. i]
local data = args['data' .. i]
-- Skip the row if label or data is "", "Meter", "Kilogramm", or "[[]]"
if label and data and label ~= "" and data ~= "" and
label ~= "Meter" and data ~= "Meter" and
label ~= "Kilogramm" and data ~= "Kilogramm" and
label ~= "Liter" and data ~= "Liter" and
label ~= "[[]]" and data ~= "[[]]" then
root:tag('div')
:addClass('infobox-row')
:tag('div')
:addClass('infobox-label')
:wikitext(label)
:done()
:tag('div')
:addClass('infobox-data')
:wikitext(data)
:done()
end
end
return tostring(root)
end
function p.infobox(frame)
return infoboxTemplate(frame)
end
return p