Module:Util/pages/dpl
< Module:Util | pages
Lua error at line 18: attempt to index global 'utilsString' (a nil value).
local SEPARATOR = "#"
local function dpl(args)
local dplArgs = ""
for k, v in pairs(args) do
if k == "format" or type(v) == "table" and v.value == "format" then
mw.addWarning("<code>format</code> argument cannot be used here. Format the resulting Lua table instead.")
elseif type(v) == "table" then
for _, andedValue in ipairs(v) do
dplArgs = dplArgs .. appendArg(k, andedValue)
end
else
dplArgs = dplArgs .. appendArg(k, v)
end
end
dplArgs = dplArgs .. appendArg("format", SEPARATOR..",,%PAGE%" .. SEPARATOR .. ",")
local result = mw.getCurrentFrame():preprocess("{{#dpl:" .. dplArgs .. "}}")
if not utilsString.endsWith(result, SEPARATOR) then
return {}
end
result = string.gsub(result, SEPARATOR .. ":", SEPARATOR) -- strip : prefix from Category results
result = utilsString.trim(result, SEPARATOR)
result = utilsString.split(result, SEPARATOR)
return result
end
function appendArg(param, value)
value = tostring(value)
value = string.gsub(value, "\|", "{{!}}")
if param and value then
return "|" .. param .. "=" .. value .. "\n"
else
return ""
end
end
return dpl