Module:TemplateHelpers: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 475: | Line 475: | ||
-- Handle boolean flags | -- Handle boolean flags | ||
if options.booleanFlags then | if options.booleanFlags then | ||
-- For non-SMW case, collect property HTML fragments in a table for efficient concatenation | |||
local propertyHtml = {} | |||
for property, flagName in pairs(options.booleanFlags) do | for property, flagName in pairs(options.booleanFlags) do | ||
if args[flagName] then | if args[flagName] then | ||
| Line 480: | Line 483: | ||
mw.smw.set({[property] = "true"}) | mw.smw.set({[property] = "true"}) | ||
else | else | ||
-- Collect HTML fragments instead of concatenating strings | |||
table.insert(propertyHtml, '<div style="display:none;">') | |||
table.insert(propertyHtml, ' {{#set: ' .. property .. '=true }}') | |||
table.insert(propertyHtml, '</div>') | |||
end | end | ||
end | end | ||
end | |||
-- For non-SMW case, concatenate all property HTML fragments at once | |||
if not mw.smw and #propertyHtml > 0 then | |||
semanticOutput = semanticOutput .. "\n" .. table.concat(propertyHtml, "\n") | |||
end | end | ||
end | end | ||