Difference between revisions of "Module:ItemBox"
Line 8: | Line 8: | ||
row:tag('td'):wikitext('<b>' .. key .. '</b>') | row:tag('td'):wikitext('<b>' .. key .. '</b>') | ||
row:tag('td'):wikitext(value) | row:tag('td'):wikitext(value) | ||
+ | |||
+ | return row | ||
+ | end | ||
+ | |||
+ | function full_row(table, key, value) | ||
+ | local row = table:tag('tr') | ||
+ | |||
+ | row:tag('td'):attr('colspan', '2'):wikitext('<b>' .. key .. '</b>') | ||
return row | return row | ||
Line 23: | Line 31: | ||
table:tag('tr'):tag('td'):addClass('infobox-image'):attr('colspan', 2) | table:tag('tr'):tag('td'):addClass('infobox-image'):attr('colspan', 2) | ||
:wikitext('[[File:' .. frame.args.image .. ']]') | :wikitext('[[File:' .. frame.args.image .. ']]') | ||
+ | |||
+ | -- Item description goes right below | ||
+ | full_row(table, frame.args.description) | ||
-- Separation header | -- Separation header | ||
Line 28: | Line 39: | ||
-- Item basic attributes | -- Item basic attributes | ||
− | + | basic_row(table, 'Level', frame.args.level) | |
-- Optional values | -- Optional values |
Revision as of 12:35, 17 June 2019
Documentation for this module may be created at Module:ItemBox/doc
local export = {} local pagename = mw.title.getCurrentTitle().fullText function basic_row(table, key, value) local row = table:tag('tr') row:tag('td'):wikitext('<b>' .. key .. '</b>') row:tag('td'):wikitext(value) return row end function full_row(table, key, value) local row = table:tag('tr') row:tag('td'):attr('colspan', '2'):wikitext('<b>' .. key .. '</b>') return row end function export.show(frame) local table = mw.html.create('table'):addClass('coa-infobox'):addClass('item') -- Create title header local td = table:tag('tr'):tag('td') td:addClass('infobox-header'):attr('colspan', '2') :wikitext(frame.args.name) -- Add image box table:tag('tr'):tag('td'):addClass('infobox-image'):attr('colspan', 2) :wikitext('[[File:' .. frame.args.image .. ']]') -- Item description goes right below full_row(table, frame.args.description) -- Separation header table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2) -- Item basic attributes basic_row(table, 'Level', frame.args.level) -- Optional values if frame.args.obtained then basic_row(table, 'Obtained', frame.args.obtained) end -- Separation header table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2) return tostring(table) end return export