Module:Variable arguments: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 33: | Line 33: | ||
.. "</div></div>" | .. "</div></div>" | ||
.. "{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}" | .. "{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}" | ||
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result) | return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result) | ||
end | end | ||
| Line 99: | Line 59: | ||
end | end | ||
function p. | function p.side_banner(frame) | ||
local args = mArguments.getArgs(frame, { | local args = mArguments.getArgs(frame, { | ||
parentOnly = true | parentOnly = true | ||
}) | }) | ||
local debugg = frame.args.debug_mode or args.debug_mode | local debugg = frame.args.debug_mode or args.debug_mode | ||
local fmt = "* [[%s]]\n" | local header = frame.args.header or args.header | ||
local imgname = frame.args.image or args.image | |||
local imgsize = frame.args.image_size or args.image_size | |||
local ns_local = frame.args.ns or args.ns | |||
local fmt = "* [[%s%s]]\n" | |||
local namespace = string.lower(frame:preprocess("{{NAMESPACE}}")) | local namespace = string.lower(frame:preprocess("{{NAMESPACE}}")) | ||
local result = "" | local result = "" | ||
| Line 110: | Line 74: | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
result = result .. (v == debugg and "" or string.format(fmt, frame:preprocess(string.format("{{ucfirst:%s}}", v)))) | result = result .. (v == debugg and "" or | ||
string.format(fmt, ns_local, frame:preprocess(string.format("{{ucfirst:%s}}", v)))) | |||
i = i + 1 | i = i + 1 | ||
end | end | ||
| Line 117: | Line 82: | ||
if result == nil or utils.trim(result) == "" then | if result == nil or utils.trim(result) == "" then | ||
local arpn_s = frame:preprocess("{{ARTICLEROOTPAGENAME}} | local arpn_s = frame:preprocess("{{ARTICLEROOTPAGENAME}}") | ||
result = string.format(fmt, arpn_s) | result = string.format(fmt, ns_local, arpn_s) | ||
end | end | ||
result = "<div class=\"sidebox\" " | result = "<div class=\"sidebox\" " | ||
.. string.format("style=\"width: %ipx;\">\n", (namespace == " | .. string.format("style=\"width: %ipx;\">\n", (namespace == "Module" and 272 or 238)) | ||
.. "{|\n" | .. "{|\n" | ||
.. "|-\n" | .. "|-\n" | ||
.. "| <span class=\"sidebox-image\">[[File: | .. string.format("| <span class=\"sidebox-image\">[[File:%s|%s]]</span>", imgname, imgsize) | ||
.. " || <span class=\"sidebox-text\">" | .. " || <span class=\"sidebox-text\">" | ||
.. string.format(" | .. string.format("%s:\n%s</span>\n", | ||
header, result) | |||
.. "|}\n</div>" | .. "|}\n</div>" | ||
.. mw.getCurrentFrame():extensionTag("templatestyles", "", { | .. mw.getCurrentFrame():extensionTag("templatestyles", "", { | ||