Module:CRTBrandList: Difference between revisions
Create module to dynamically generate CRT brand list from semantic query (via create-page on MediaWiki MCP Server) |
Fix link parameter handling - only include if specified (via update-page on MediaWiki MCP Server) |
||
| Line 15: | Line 15: | ||
function p.list(frame) | function p.list(frame) | ||
local args = frame.args | local args = frame.args | ||
local linkType = args.link | local linkType = trim(args.link) | ||
-- Query all CRT models and get their brands | -- Query all CRT models and get their brands | ||
| Line 55: | Line 55: | ||
local output = {} | local output = {} | ||
for _, brand in ipairs(brandsList) do | for _, brand in ipairs(brandsList) do | ||
local templateCall = '{{Brand entry|brand=' .. brand .. '|link=' .. linkType .. '}}' | local templateCall | ||
if linkType then | |||
templateCall = '{{Brand entry|brand=' .. brand .. '|link=' .. linkType .. '}}' | |||
else | |||
templateCall = '{{Brand entry|brand=' .. brand .. '}}' | |||
end | |||
table.insert(output, frame:preprocess(templateCall)) | table.insert(output, frame:preprocess(templateCall)) | ||
end | end | ||