Module:Sandbox/BU Rob13: Difference between revisions
Appearance
Content deleted Content added
add support for country importance |
allow class/importance even if blank |
||
Line 51: | Line 51: | ||
if i == 0 or i > 2 then |
if i == 0 or i > 2 then |
||
print("{{WikiProject Central America") |
print("{{WikiProject Central America") |
||
printfd("| class = %s", args.class) |
|||
printfd("| importance = %s", args.importance) |
|||
end |
|||
if args.importance then |
|||
printfd("| importance = %s", args.importance) |
|||
end |
|||
if args.attention then |
if args.attention then |
||
printfd("| attention = %s", args.attention) |
printfd("| attention = %s", args.attention) |
||
Line 78: | Line 74: | ||
if args.Belize == "yes" then |
if args.Belize == "yes" then |
||
print("{{WikiProject Belize") |
print("{{WikiProject Belize") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.Belizeimportance then |
if args.Belizeimportance then |
||
printfd("| importance = %s", args.Belizeimportance) |
printfd("| importance = %s", args.Belizeimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 99: | Line 93: | ||
if args.CostaRica == "yes" then |
if args.CostaRica == "yes" then |
||
print("{{WikiProject Costa Rica") |
print("{{WikiProject Costa Rica") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.CostaRicaimportance then |
if args.CostaRicaimportance then |
||
printfd("| importance = %s", args.CostaRicaimportance) |
printfd("| importance = %s", args.CostaRicaimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 120: | Line 112: | ||
if args.ElSalvador == "yes" then |
if args.ElSalvador == "yes" then |
||
print("{{WikiProject El Salvador") |
print("{{WikiProject El Salvador") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.ElSalvadorimportance then |
if args.ElSalvadorimportance then |
||
printfd("| importance = %s", args.ElSalvadorimportance) |
printfd("| importance = %s", args.ElSalvadorimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 141: | Line 131: | ||
if args.Guatemala == "yes" then |
if args.Guatemala == "yes" then |
||
print("{{WikiProject Guatemala") |
print("{{WikiProject Guatemala") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.Guatemalaimportance then |
if args.Guatemalaimportance then |
||
printfd("| importance = %s", args.Guatemalaimportance) |
printfd("| importance = %s", args.Guatemalaimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 162: | Line 150: | ||
if args.Honduras == "yes" then |
if args.Honduras == "yes" then |
||
print("{{WikiProject Honduras") |
print("{{WikiProject Honduras") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.Hondurasimportance then |
if args.Hondurasimportance then |
||
printfd("| importance = %s", args.Hondurasimportance) |
printfd("| importance = %s", args.Hondurasimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 183: | Line 169: | ||
if args.Nicaragua == "yes" then |
if args.Nicaragua == "yes" then |
||
print("{{WikiProject Nicaragua") |
print("{{WikiProject Nicaragua") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.Nicaraguaimportance then |
if args.Nicaraguaimportance then |
||
printfd("| importance = %s", args.Nicaraguaimportance) |
printfd("| importance = %s", args.Nicaraguaimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
||
Line 204: | Line 188: | ||
if args.Panama == "yes" then |
if args.Panama == "yes" then |
||
print("{{WikiProject Panama") |
print("{{WikiProject Panama") |
||
printfd("| class = %s", args.class) |
|||
printfd("| class = %s", args.class) |
|||
⚫ | |||
if args.Panamaimportance then |
if args.Panamaimportance then |
||
printfd("| importance = %s", args.Panamaimportance) |
printfd("| importance = %s", args.Panamaimportance) |
||
⚫ | |||
elseif args.importance then |
|||
printfd("| importance = %s", args.importance) |
printfd("| importance = %s", args.importance) |
||
end |
end |
Revision as of 03:18, 14 February 2017
-- [SublimeLinter luacheck-globals:mw]
-- This module serves to convert [[Template:WikiProject Central America]] from
-- using country task forces to the new country WikiProject templates.
-- Due to some changes of parameters needed for this module to run, it
-- SHOULD NOT be run by anyone other than the module author without consultation
-- Direct questions to User talk:BU Rob13.
local p = {}
local getBuffer, print = require("Module:OutputBuffer")()
local function printfd(formatString, ...)
local default = ""
local args, argsNum = {...}, select("#", ...)
local newArgs = {}
for i = 1, argsNum do
if args[i] ~= nil then
table.insert(newArgs, args[i])
else
table.insert(newArgs, default)
end
end
print(string.format(formatString, unpack(newArgs)))
end
function p._main(args)
local i = 0
if args.Belize == "yes" then
i = i + 1
end
if args.CostaRica == "yes" then
i = i + 1
end
if args.ElSalvador == "yes" then
i = i + 1
end
if args.Guatemala == "yes" then
i = i + 1
end
if args.Honduras == "yes" then
i = i + 1
end
if args.Nicaragua == "yes" then
i = i + 1
end
if args.Panama == "yes" then
i = i + 1
end
if i == 0 or i > 2 then
print("{{WikiProject Central America")
printfd("| class = %s", args.class)
printfd("| importance = %s", args.importance)
if args.attention then
printfd("| attention = %s", args.attention)
end
if args.needsinfobox then
printfd("| needs-infobox = %s", args.needsinfobox)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if i == 1 or i == 2 then
if args.Belize == "yes" then
print("{{WikiProject Belize")
printfd("| class = %s", args.class)
if args.Belizeimportance then
printfd("| importance = %s", args.Belizeimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.CostaRica == "yes" then
print("{{WikiProject Costa Rica")
printfd("| class = %s", args.class)
if args.CostaRicaimportance then
printfd("| importance = %s", args.CostaRicaimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.ElSalvador == "yes" then
print("{{WikiProject El Salvador")
printfd("| class = %s", args.class)
if args.ElSalvadorimportance then
printfd("| importance = %s", args.ElSalvadorimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.Guatemala == "yes" then
print("{{WikiProject Guatemala")
printfd("| class = %s", args.class)
if args.Guatemalaimportance then
printfd("| importance = %s", args.Guatemalaimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.Honduras == "yes" then
print("{{WikiProject Honduras")
printfd("| class = %s", args.class)
if args.Hondurasimportance then
printfd("| importance = %s", args.Hondurasimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.Nicaragua == "yes" then
print("{{WikiProject Nicaragua")
printfd("| class = %s", args.class)
if args.Nicaraguaimportance then
printfd("| importance = %s", args.Nicaraguaimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
if args.Panama == "yes" then
print("{{WikiProject Panama")
printfd("| class = %s", args.class)
if args.Panamaimportance then
printfd("| importance = %s", args.Panamaimportance)
else
printfd("| importance = %s", args.importance)
end
if args.small then
printfd("| small = %s", args.small)
end
if args.listas then
printfd("| listas = %s", args.listas)
end
if args.category then
printfd("| category = %s", args.category)
end
print("}}")
end
end
return getBuffer("\n")
end
function p.main(frame)
local args = require("Module:Arguments").getArgs(frame)
return p._main(args)
end
return p