Anonymous user
Module:Flagg: Difference between revisions
Support text callback for {{flagathlete}}. Correct incorrect escape character.
Richardpruen (talk | contribs) m (1 revision imported) |
imported>GKFX (Support text callback for {{flagathlete}}. Correct incorrect escape character.) |
||
Line 1: | Line 1: | ||
local titleSelf = mw.title.new(... or mw.getCurrentFrame():getTitle()) | |||
local titleCountryData = mw.title.new[[Module:CountryData]] | |||
if titleSelf.isSubpage then | |||
local sandbox = titleSelf.subpageText:match[[^sandbox]] | |||
if sandbox then | |||
titleCountryData = titleCountryData:subPageTitle(sandbox) | |||
end | |||
end | |||
local CountryData = require(tostring(titleCountryData)) | |||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
Line 52: | Line 60: | ||
local aalias | local aalias | ||
amap, aalias = require("Module:Flagg/Altvar data").alttable(age) | amap, aalias = require("Module:Flagg/Altvar data").alttable(age) | ||
avar = string.gsub(string.lower(avar or ""),"[ | avar = string.gsub(string.lower(avar or ""),"[ -]","") | ||
avar = aalias[avar] or avar | avar = aalias[avar] or avar | ||
if not amap[avar] then error("Unknown avar") end | if not amap[avar] then error("Unknown avar") end | ||
Line 188: | Line 196: | ||
text = clink=="" and name or "[["..clink..csec.."|"..name.."]]" | text = clink=="" and name or "[["..clink..csec.."|"..name.."]]" | ||
end | end | ||
end | |||
if type(text) == 'function' then | |||
text = text(data) | |||
end | end | ||
Line 250: | Line 262: | ||
out = text.."<span class=\"flagicon\"><br/>"..image.."</span>" | out = text.."<span class=\"flagicon\"><br/>"..image.."</span>" | ||
elseif ms=="t" then --table cell | elseif ms=="t" then --table cell | ||
out = "style=\"text-align:"..(nalign or "left").."\"|"..text.."||style=\"text-align:"..(align or "center").." | out = "style=\"text-align:"..(nalign or "left").."\"|"..text.."||style=\"text-align:"..(align or "center").."\"|<span class=\"flagicon\">"..image.."</span>" | ||
else --fixed-width span box (default) | else --fixed-width span box (default) | ||
local width = args["width"] or args["w"] or require("Module:Flaglist").luawidth(size) | local width = args["width"] or args["w"] or require("Module:Flaglist").luawidth(size) | ||
out = text.." <span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "right").." | out = text.." <span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "right").."\">"..image.."</span>" | ||
end | end | ||
else --image left of name | else --image left of name | ||
Line 268: | Line 280: | ||
else --fixed-width span box (default) | else --fixed-width span box (default) | ||
local width = nopx(args["width"] or args["w"]) or require("Module:Flaglist").luawidth(size) | local width = nopx(args["width"] or args["w"]) or require("Module:Flaglist").luawidth(size) | ||
out = "<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "left").." | out = "<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "left").."\">"..image.."</span> "..text | ||
end | end | ||
end | end |