Module:Item Information: Difference between revisions
Jump to navigation
Jump to search
Created page with "local p = {} local paramTest = require('Module:Paramtest') local onMain = require('Module:Mainonly').on_main local yesNo = require('Module:Yesno') -- Add error checking for SMW local smw = mw.smw if not smw then mw.log('SMW Lua bridge not available') smw = { set = function() return nil end -- Stub function that does nothing } end function buildRow(item, info) local row = mw.html.create('tr') row:tag('td'):wikitext(item) row:tag('td'):w..." |
No edit summary |
||
Line 4: | Line 4: | ||
local onMain = require('Module:Mainonly').on_main | local onMain = require('Module:Mainonly').on_main | ||
local yesNo = require('Module:Yesno') | local yesNo = require('Module:Yesno') | ||
function buildRow(item, info) | function buildRow(item, info) | ||
local row = mw.html.create('tr') | local row = mw.html.create('tr') | ||
row:tag('td'):wikitext(item) | row:tag('td'):wikitext(item) | ||
row:tag('td'):wikitext(info) | row:tag('td'):wikitext(info or 'N/A') | ||
return row | return row | ||
end | end | ||
Line 28: | Line 19: | ||
end | end | ||
-- Create header row | |||
ret:tag('tr') | ret:tag('tr') | ||
:tag('th'):wikitext('Item'):done() | :tag('th'):wikitext('Item'):done() | ||
:tag('th'):wikitext('Additional Information'):done() | :tag('th'):wikitext('Additional Information'):done() | ||
-- Add item rows | |||
-- | for i = 1, 20 do -- Support up to 20 items | ||
for i = 1, | |||
local item = args['item' .. i] | local item = args['item' .. i] | ||
local info = args['info' .. i] | local info = args['info' .. i] | ||
if(paramTest.has_content(item | if(paramTest.has_content(item)) then | ||
ret:node(buildRow(item, info)) | ret:node(buildRow(item, info)) | ||
end | end | ||
end | end | ||
Line 64: | Line 38: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
return p._main(args) | return p._main(args) | ||
end | end | ||
return p | return p |
Latest revision as of 00:54, 3 May 2025
Documentation for this module may be created at Module:Item Information/doc
local p = {}
local paramTest = require('Module:Paramtest')
local onMain = require('Module:Mainonly').on_main
local yesNo = require('Module:Yesno')
function buildRow(item, info)
local row = mw.html.create('tr')
row:tag('td'):wikitext(item)
row:tag('td'):wikitext(info or 'N/A')
return row
end
function p._main(args)
local ret = mw.html.create('table'):addClass('wikitable sticky-header')
if(paramTest.has_content(args.title)) then
ret:tag('caption'):wikitext(args.title)
end
-- Create header row
ret:tag('tr')
:tag('th'):wikitext('Item'):done()
:tag('th'):wikitext('Additional Information'):done()
-- Add item rows
for i = 1, 20 do -- Support up to 20 items
local item = args['item' .. i]
local info = args['info' .. i]
if(paramTest.has_content(item)) then
ret:node(buildRow(item, info))
end
end
return ret
end
function p.main(frame)
local args = frame:getParent().args
return p._main(args)
end
return p