Module:MakeListHTML
Jump to navigation
Jump to search
Documentation for this module may be created at Module:MakeListHTML/doc
local p = {}
local cargo = mw.ext.cargo
local listText = ''
function p.main(f)
local fArgs = f.args
local tables = fArgs.tableName
local fields = fArgs.listField..','.. fArgs.tipField
-- local fields = 'LinkText, Map'
local whereClause = fArgs.keyField..'="'..fArgs.keyValue..'"'
local wrapBrackets = fArgs.WrapLinkBrackets or ''
local suppressBullets = fArgs.SuppressBullets or ''
local tblArgs = {
where = whereClause,
orderBy = fArgs.orderField or fArgs.listField
}
-- load cargo data to results
local results = cargo.query( tables, fields, tblArgs )
local returnHTML = '<ul>'
for r = 1, #results do
local result = results[r]
local toolTip = result[fArgs.tipField] or ''
local listHeader = '<li><span title="'
if wrapBrackets == 'true'
then
-- listText = "[["..result[fArgs.listField].."]]"
listText = "{{ItemNameWithIcon|"..result[fArgs.listField].."}}"
else
listText = result[fArgs.listField] or ''
end
if suppressBullets == 'true'
then
listHeader = '<li style="list-style-type: none;"><span title="'
end
if fArgs.tipField == ''
then
returnHTML = returnHTML..'<li>'..listText..'</li>'
else
returnHTML = returnHTML..listHeader..toolTip..'">'..listText..'</span></li>'
end
--]]
end
returnHTML = returnHTML..'</ul>'
return f:preprocess(returnHTML)
end
return p