Module:T-Campaign: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 10: | Line 10: | ||
local DatasetLoader = require('Module:DatasetLoader') | local DatasetLoader = require('Module:DatasetLoader') | ||
local WikitextProcessor = require('Module:WikitextProcessor') | local WikitextProcessor = require('Module:WikitextProcessor') | ||
local TemplateHelpers = require('Module:TemplateHelpers') | |||
local TemplateStructure = require('Module:TemplateStructure') | |||
-- Register the Campaign template with Blueprint | -- Register the Campaign template with Blueprint | ||
| Line 131: | Line 133: | ||
return campaignName | return campaignName | ||
end | |||
-- Helper function: Get recursion depth from frame arguments | |||
local function getRecursionDepth(frame) | |||
local frameArgs = frame.args or {} | |||
local parentArgs = (frame:getParent() and frame:getParent().args) or {} | |||
return tonumber(frameArgs._recursion_depth or parentArgs._recursion_depth) or 0 | |||
end | end | ||
| Line 431: | Line 441: | ||
template.current_frame = frame | template.current_frame = frame | ||
local depth = | local depth = getRecursionDepth(frame) | ||
if depth > 3 then | if depth > 3 then | ||
| Line 458: | Line 463: | ||
for k, v in pairs(frameArgs) do args[k] = v end | for k, v in pairs(frameArgs) do args[k] = v end | ||
args = | args = TemplateHelpers.normalizeArgumentCase(args) | ||
args._recursion_depth = tostring(depth + 1) | args._recursion_depth = tostring(depth + 1) | ||
args = Blueprint.runPreprocessors(template, args) | args = Blueprint.runPreprocessors(template, args) | ||
| Line 483: | Line 487: | ||
end | end | ||
local result = TemplateStructure.render(args, structureConfig, template._errorContext) | local result = TemplateStructure.render(args, structureConfig, template._errorContext) | ||