Module:T-Campaign: Difference between revisions
// via Wikitext Extension for VSCode Tag: Manual revert |
// via Wikitext Extension for VSCode |
||
| Line 183: | Line 183: | ||
end | end | ||
-- Step 1: Get the raw title value | |||
local rawTitle = args._campaign_data.defaults.title or "Campaign" | |||
local finalTitle = rawTitle | |||
-- Step 2: Inspect the raw title's type and content | |||
local rawType = type(rawTitle) | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Inspecting raw title', 'Type: ' .. rawType) | |||
if rawType == 'table' then | |||
-- If it's a table, we need to serialize it to see what's inside. | |||
-- This is a simple serializer for demonstration. | |||
local serialized = "{" | |||
for k, v in pairs(rawTitle) do | |||
serialized = serialized .. ' [' .. tostring(k) .. '] = "' .. tostring(v) .. '",' | |||
end | |||
if serialized:sub(-1) == ',' then | |||
serialized = serialized:sub(1, -2) | |||
end | |||
serialized = serialized .. " }" | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Raw title is a table', 'Serialized content: ' .. serialized) | |||
-- Attempt to extract a string value. Let's assume the first value is what we want. | |||
if rawTitle[1] then | |||
finalTitle = tostring(rawTitle[1]) | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Extracted value from table', 'Using value at index 1: "' .. finalTitle .. '"') | |||
else | |||
-- Fallback if we can't find a value at index 1 | |||
finalTitle = tostring(rawTitle) | |||
end | |||
elseif rawType ~= 'string' then | |||
-- Handle other non-string, non-table types | |||
finalTitle = tostring(rawTitle) | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Raw title is not a string or table', 'Using tostring() conversion: "' .. finalTitle .. '"') | |||
end | |||
-- Step 3: Use the processed title for the placeholder | |||
local placeholderValues = { | local placeholderValues = { | ||
CAMPAIGN_NAME = | CAMPAIGN_NAME = finalTitle | ||
} | } | ||
ErrorHandling.addStatus(context, 'campaignBanner', 'Final placeholder value set', 'CAMPAIGN_NAME = "' .. finalTitle .. '"') | |||
bannerContent = WikitextProcessor.processContentForFrontend(bannerContent, placeholderValues, context) | bannerContent = WikitextProcessor.processContentForFrontend(bannerContent, placeholderValues, context) | ||