Module:Flagg: Difference between revisions

Support text callback for {{flagathlete}}. Correct incorrect escape character.
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 = {}
local CountryData = require('Module:CountryData/sandbox')


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")..";\"|<span class=\"flagicon\">"..image.."</span>"
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.."&nbsp;<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "right")..";\">"..image.."</span>"
out = text.."&nbsp;<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")..";\">"..image.."</span>&nbsp;"..text
out = "<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "left").."\">"..image.."</span>&nbsp;"..text
end
end
end
end
Anonymous user