Module:Lang: Difference between revisionsGive feedback
Jump to navigation
Jump to search
fixed error when no label colour assigned |
Gammaton32 (talk | contribs) omit empty links in processed inline_attribute tags |
||
| Line 68: | Line 68: | ||
-- Process citadel_inline_attribute tags | -- Process citadel_inline_attribute tags | ||
text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key) | |||
local replacement = replacements[key] | |||
if | if replacement then | ||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s | local label_color = replacement.label_color or 'inherit' | ||
local icon = replacement.icon or '' | |||
local link = replacement.link or '' | |||
-- pre-process string, then check to omit link if the string is empty | |||
local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}') | |||
if translated == '' then | |||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s</span>', label_color, icon) | |||
else | else | ||
return '<span style=" | return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s [[%s|%s]]</span>', | ||
label_color, | |||
icon, | |||
link, | |||
translated) | |||
end | end | ||
end) | else | ||
return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing attribute definition - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>' | |||
end | |||
end) | |||
return frame:preprocess(text) | |||
end | end | ||