Content added Content deleted
mNo edit summary |
mNo edit summary |
||
Line 3: | Line 3: | ||
local function _resolve_pipe(text) |
local function _resolve_pipe(text) |
||
local func = text:gmatch("|.*") |
local func = text:gmatch("|.*") |
||
local data = func() |
|||
if data ~= nil then return data:sub(2) else return text end |
|||
end |
end |
||
Line 22: | Line 23: | ||
function mod.resolve_pipe(frame) |
function mod.resolve_pipe(frame) |
||
local args, pargs = mod.get_args_and_pargs(frame) |
local args, pargs = mod.get_args_and_pargs(frame) |
||
local pipe = args[1] or pargs[1] or "" |
local pipe = args[1] or pargs[1] or "TBA" |
||
return mod.resolve_text(pipe) |
return mod.resolve_text(pipe) |
||
end |
end |
Revision as of 21:51, May 13, 2024
Documentation for this module may be created at Module:Util/doc
---@param text string
---@return string
local function _resolve_pipe(text)
local func = text:gmatch("|.*")
local data = func()
if data ~= nil then return data:sub(2) else return text end
end
---@return table, table
local function _get_args_and_pargs(frame)
local args = frame.args
local parent = frame:getParent()
local pargs={}
if parent then pargs=parent.args end
return args, pargs
end
local mod = {
get_args_and_pargs = _get_args_and_pargs,
resolve_text = _resolve_pipe
}
function mod.resolve_pipe(frame)
local args, pargs = mod.get_args_and_pargs(frame)
local pipe = args[1] or pargs[1] or "TBA"
return mod.resolve_text(pipe)
end
return mod