Module:T-Campaign: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 187: | Line 187: | ||
local finalTitle = rawTitle | local finalTitle = rawTitle | ||
-- Step 2: | -- Step 2: Launder the string to work around suspected Scribunto bug | ||
local | local function launderString(inputStr) | ||
if type(inputStr) ~= 'string' then return tostring(inputStr) end | |||
local newStr = "" | |||
for i = 1, #inputStr do | |||
newStr = newStr .. string.char(string.byte(inputStr, i)) | |||
end | |||
return newStr | |||
end | |||
local cleanTitle = launderString(rawTitle) | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Laundered String', 'Original Type: ' .. type(rawTitle) .. ', Cleaned Value: "' .. cleanTitle .. '"') | |||
-- If it's a table, we need to serialize it to see what's inside. | |||
if type(rawTitle) == 'table' then | |||
-- If it's a table, we need to serialize it to see what's inside. | -- If it's a table, we need to serialize it to see what's inside. | ||
-- This is a simple serializer for demonstration. | -- This is a simple serializer for demonstration. | ||
| Line 227: | Line 217: | ||
-- Attempt to extract a string value. Let's assume the first value is what we want. | -- Attempt to extract a string value. Let's assume the first value is what we want. | ||
if rawTitle[1] then | if rawTitle[1] then | ||
cleanTitle = launderString(tostring(rawTitle[1])) | |||
ErrorHandling.addStatus(context, 'campaignBanner', 'Extracted value from table', 'Using value at index 1: "' .. | ErrorHandling.addStatus(context, 'campaignBanner', 'Extracted value from table', 'Using value at index 1: "' .. cleanTitle .. '"') | ||
else | else | ||
-- Fallback if we can't find a value at index 1 | -- Fallback if we can't find a value at index 1 | ||
cleanTitle = launderString(tostring(rawTitle)) | |||
end | end | ||
end | end | ||
-- Step 3: Use the processed title for the placeholder | -- Step 3: Use the processed title for the placeholder | ||
local placeholderValues = { | local placeholderValues = { | ||
CAMPAIGN_NAME = | CAMPAIGN_NAME = cleanTitle | ||
} | } | ||