Tim (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „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 for i = 1, 50 do local label = args['label' .. i] local data = args['data' .. i] if not label or not data…“) |
K (10 Versionen importiert) |
||
(9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 11: | Zeile 11: | ||
:addClass('infobox-title') | :addClass('infobox-title') | ||
:wikitext(args['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 | end | ||
Zeile 16: | 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