Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/pppery/flaglist
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local clone = require("Module:TableTools").shallowClone local size = require("Module:TableTools").size function p.expandTemplate2(frame) return p.expandTemplate(frame.args[1], frame.args[2], frame.args[3], frame.args.n) end function p.expandTemplate(temp, arg, arg2, n) local frame = mw.getCurrentFrame() local raw = frame:expandTemplate{title=temp, args={arg,arg2}} -- Force full subst while raw:find("{{") do raw = raw:gsub("{{","{{subst:") raw = raw:gsub("subst:subst:","subst:"):gsub("subst: \n","subst:") -- hack to subst #switch last raw = raw:gsub("{{subst:#switch","{{#switch") if not raw:find("{{subst:") then raw = raw:gsub("{{#switch","{{subst:#switch") end if n ~= nil then n = n - 1 if n == 0 then return raw end end raw = frame:preprocess(raw) end return raw end function p.main(frame) local args = clone(frame.args) local tail = "" args.more = nil if args.notes then tail = tail .. " " .. args.notes args.notes = nil end if args.subregion then tail = tail .. " ||style=text-align:center|[[" .. p.expandTemplate("UN subregion", args[2]) .. ']]' args.subregion = nil end if args["regional-group"] then tail = tail .. " ||style=text-align:center|[[" .. p.expandTemplate("Regional group", args[2]) .. ']]' args["regional-group"] = nil end if args.region then tail = tail .. " ||style=text-align:center|[[" .. p.expandTemplate("UN region", args[2]) .. ']]' args.region = nil end if args[3] then args.variant = args[3] args[3] = nil end local templatename = "flagg" local newArgs = {} if args.noflag then newArgs[1] = "x" args.noflag = nil else newArgs[1] = "u" end -- numbered params if args.table then newArgs[1] = newArgs[1] .. "s*eft" args.table = nil else newArgs[1] = newArgs[1] .. "s*ef" end newArgs[2] = args[2]; args[2] = nil -- common named params newArgs.pref = args[1]; args[1] = nil newArgs.size = args.size; args.size = nil newArgs.variant = args.variant or args[3]; args.variant = nil; args[3] = nil newArgs.name = args.name; args.name = nil; newArgs.align = args.align; args.align = nil; -- special named params newArgs.psection = args.section; args.section = nil; newArgs.pref2 = args.alt; args.alt = nil newArgs.psection2 = args["alt-section"]; args["alt-section"] = nil newArgs.plink = args.link; args.link = nil if p.expandTemplate("thecountry",newArgs[2]) ~= "" then newArgs.the = "y" end if size(args) ~= 0 then error("Unaccounted parameters") end return require("Module:Template invocation").invocation("flagg", newArgs) .. tail end function p.asteriskNote(frame) -- This code uglily copied from [[Module:Template parameter value]] and hacked local content = string.gsub(mw.title.getCurrentTitle():getContent() or "", "[\r\n]", "") content = string.match(content, '{{flaglist%+link(.+)') local prefix = "" while prefix == "" or prefix:find("=") do content = string.match(content, '|%s*([^|].*)') prefix = string.match(content, '^([^|}]*{{[^}]+}}[^|}]*)|') or string.match(content, '([^|}]+)') end prefix = string.gsub(prefix, "^%s*(.-)%s*$", "%1") if prefix == "" then return end local alt = frame:expandTemplate{title="template parameter value",args={mw.title.getCurrentTitle().fullText,"flaglist+link","1","alt","1"}} if alt == "" then return "\n<big><big>'''*'''</big></big> indicates '''\"" .. prefix .. " COUNTRY or TERRITORY\"''' links.\n" else return "\n<big><big>'''*'''</big></big> indicates '''\"" .. prefix .. " COUNTRY or TERRITORY\"''' or '''\"" .. alt .. " COUNTRY or TERRITORY\"''' links.\n" end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/pppery/flaglist/doc
(
edit
)