Module:Variable arguments: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 6: Line 6:
     parentOnly = true
     parentOnly = true
     })
     })
local out_str = ""
local result = ""
local i = 0
local i = 0
for k, v in pairs(args) do
for k, v in pairs(args) do
out_str = out_str .. string.format("* [[Module:%s]]\n", v)
result = result .. string.format("* [[Module:%s]]\n", v)
i = i + 1
i = i + 1
end
end
out_str = out_str:sub(1, -2)
result = result:sub(1, -2)
if out_str == "" or out_str == nil then
if result == "" or result == nil then
out_str = "* [[Module:{{ROOTPAGENAME}}]]\n"
result = "* [[Module:{{ROOTPAGENAME}}]]\n"
end
end
out_str = "<div style=\"border-collapse: collapse; border: 1px solid #a2a9b1;"
result = "<div style=\"border-collapse: collapse; border: 1px solid #a2a9b1;"
.. " background-color: #f8f9fa; box-sizing: border-box; clear: right; "
.. " background-color: #f8f9fa; box-sizing: border-box; clear: right; "
.. "color: #202122; float: right; font-size: 16px; margin: 0 0 4px 4px; width: 238px;\">\n"
.. "color: #202122; float: right; font-size: 16px; margin: 0 0 4px 4px; width: 238px;\">\n"
Line 29: Line 29:
.. " || <span style=\"display: inline-block; font-size: 0.88em; "
.. " || <span style=\"display: inline-block; font-size: 0.88em; "
.. "line-height: 110%; padding: 0.22em 0.22em 0.22em 0.792em;\">"
.. "line-height: 110%; padding: 0.22em 0.22em 0.22em 0.792em;\">"
.. string.format("This template uses {{w|WP:Lua|Lua}}:\n%s</span>\n", out_str)
.. string.format("This template uses {{w|WP:Lua|Lua}}:\n%s</span>\n", result)
.. "|}</div>"
.. "|}</div>"
return frame:preprocess(out_str)
return frame:preprocess(result)
end
end


Line 38: Line 38:
     parentOnly = true
     parentOnly = true
     })
     })
local out_str = ""
local result = ""
local i = 0
local i = 0
for k, v in pairs(args) do
for k, v in pairs(args) do
out_str = out_str .. string.format("<span style=\"white-space: nowrap;\">%s</span>, ",
result = result .. string.format("<span style=\"white-space: nowrap;\">%s</span>, ",
string.gsub(v, "^%s*(.-)%s*$", "%1"))
string.gsub(v, "^%s*(.-)%s*$", "%1"))
i = i + 1
i = i + 1
end
end
out_str = out_str:sub(1, -3)
result = result:sub(1, -3)
return frame:preprocess(out_str)
return frame:preprocess(result)
end
end


Line 55: Line 55:
parentOnly = true
parentOnly = true
})
})
local out_str = ""
local result = ""
local i = 0
local i = 0
Line 62: Line 62:
if string.lower(v) ~= "false" and string.lower(v) ~= "true" then
if string.lower(v) ~= "false" and string.lower(v) ~= "true" then
out_str = out_str .. "<div style=\"margin-left: 10px;\">"
result = result .. "<div style=\"margin-left: 10px;\">"
.. string.format("'''[[wikipedia:%s|%s]]'''", v, v)
.. string.format("'''[[wikipedia:%s|%s]]'''", v, v)
.. "</div>\n"
.. "</div>\n"
Line 69: Line 69:
end
end
if out_str == "" then
if result == "" then
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
out_str = "<div style=\"margin-left: 10px;\">"
result = "<div style=\"margin-left: 10px;\">"
.. string.format("'''[[wikipedia:%s|%s]]'''", arpn, arpn)
.. string.format("'''[[wikipedia:%s|%s]]'''", arpn, arpn)
.. "</div>\n" .. out_str
.. "</div>\n" .. result
end
end
out_str = "<div style=\"background: #f9f9f9; border: 1px solid #aaa; clear: right; float: right; "
result = "<div style=\"background: #f9f9f9; border: 1px solid #aaa; clear: right; float: right; "
.. "font-size: 90%; width: 300px; margin: 0 0 4px 4px; padding: 4px; text-align: left;\">\n"
.. "font-size: 90%; width: 300px; margin: 0 0 4px 4px; padding: 4px; text-align: left;\">\n"
    .. "<div style=\"float: left;\">[[File:Wikipedia-logo.png|44px|none|link=|alt=]]</div>\n"
    .. "<div style=\"float: left;\">[[File:Wikipedia-logo.png|44px|none|link=|alt=]]</div>\n"
    .. "<div style=\"margin-left: 60px;\">"
    .. "<div style=\"margin-left: 60px;\">"
    .. string.format("English [[Wikipedia:Main Page|Wikipedia]] has %s on:\n%s</div>", (i > 1 and "articles" or "an article"), out_str)
    .. string.format("English [[Wikipedia:Main Page|Wikipedia]] has %s on:\n%s</div>", (i > 1 and "articles" or "an article"), result)
    .. "{{clear}}</div>"
    .. "{{clear}}</div>"
return frame:preprocess(out_str)
return frame:preprocess(result)
end
end


Line 89: Line 89:
     parentOnly = true
     parentOnly = true
     })
     })
local out_str = ""
local result = ""
local i = 0
local i = 0


Line 96: Line 96:
for k, v in pairs(args) do
for k, v in pairs(args) do
         pname = pname .. v
         pname = pname .. v
out_str = out_str .. string.format("[[%s|%s]] {{pipe}} ", pname, v)
result = result .. string.format("[[%s|%s]] {{pipe}} ", pname, v)
i = i + 1
i = i + 1
         pname = pname .. "/"
         pname = pname .. "/"
end
end


     out_str = out_str:sub(1, -11)
     result = result:sub(1, -11)
if out_str == "" or out_str == nil then
if result == "" or result == nil then
out_str = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
result = "[[{{#titleparts: {{FULLPAGENAME}}|-1}}]]"
end
end
out_str = "<div id=\"contentSub\">"
result = "<div id=\"contentSub\">"
.. "<div style=\"margin: 0.5em;\"></div>"
.. "<div style=\"margin: 0.5em;\"></div>"
.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>"
.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>"
.. "<div style=\"margin: 0em;\">"
.. "<div style=\"margin: 0em;\">"
.. string.format("<span class=\"subpages\">&lt; %s</span>", out_str)
.. string.format("<span class=\"subpages\">&lt; %s</span>", result)
.. "</div></div>"
.. "</div></div>"
return frame:preprocess(out_str)
return frame:preprocess(result)
end
end


return p
return p