« Module:Script » : différence entre les versions
Utilisation d'une "vraie" frame |
Aucun résumé des modifications |
||
Ligne 5 : | Ligne 5 : | ||
function Script:new(frame) | function Script:new(frame) | ||
self.__index = self | self.__index = self | ||
self.template = frame.args[1] | self.template = frame.args[1] | ||
self.arguments = frame.args[2] | self.arguments = frame.args[2] |
Version du 5 mars 2025 à 00:23
La documentation pour ce module peut être créée à Module:Script/doc
local Script = {}
local String = require('Module:String')
local p = {}
function Script:new(frame)
self.__index = self
self.template = frame.args[1]
self.arguments = frame.args[2]
return self
end
function Script:build()
local root = mw.html.create()
local command = self.template
for key, value in pairs(self.arguments) do
if value ~= nil then
command = String:replace(frame:newChild{title = "module invocation", args = {source = command, pattern = "{" .. key .. "}", replace = value}})
end
end
root:wikitext(command)
return tostring(root)
end
function p:main(frame)
local script = Script:new(frame)
return script:build()
end
return p