Module:$var/doc: Difference between revisions

From Saintapedia
Jump to navigation Jump to search
(Created page with "{{Shared Template Warning|Module:$var}} {{Module rating|alpha}} <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> Lua module for rendering the source of template transclusions using {{mono|{{ll|Help:Extension:Translate/Page translation administration#Variables|${{var|var}}}}}}. == Usage == <code><nowiki>{{</nowiki>#invoke:$var|$''var_name''<nowiki>}}</nowiki></code> <includeonly>{{Sandbox other|| <!-- Categories below this li...")
 
No edit summary
Tag: Reverted
Line 1: Line 1:
{{Shared Template Warning|Module:$var}}
{{Module:$var}}
{{Module rating|alpha}}
{{Module rating|alpha}}
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->

Revision as of 22:10, 7 September 2024

-- <nowiki>


-- Lua module for rendering the source of template transclusions using -- $var. -- -- @module $var -- @alias p -- @author User:ExE Boss -- @require Module:Arguments


require("strict") local getArgs = require("Module:Arguments").getArgs

local function echoSource(name, args) local content = mw.html.create() local unnamed = {} content:wikitext("{{", name) for i, v in ipairs(args) do unnamed[i] = true -- unnamed arguments can have leading and trailing whitespace content:wikitext("|", v) -- XXX: escaped "|" and "=" as "|" and "="? end for k, v in pairs(args) do if not unnamed[k] then content:wikitext("|", k, "=", v) -- XXX: escaped "|" as "|"? end end content:wikitext("}}") return tostring(mw.html.create("code"):wikitext(mw.text.nowiki(tostring(content:allDone()))):allDone()) end

local mt = {} function mt.__index(t, name) if type(name) == "string" and mw.ustring.find(name, "^%$.") then return function(frame) local args = getArgs(frame, { trim = false, removeBlanks = false, wrappers = { "Template:$1", "Template:$2", "Template:$3", "Template:$4", "Template:$5", "Template:$6", "Template:$7", "Template:$8", "Template:$9", }, }) return echoSource(name, args) end end end

return setmetatable({}, mt)

Lua module for rendering the source of template transclusions using Template:Mono.

Usage

{{#invoke:$var|$var_name}}


[[Category:Module documentation pages{{#translation:}}]]