24,540
ARTICLES
ON THIS WIKI
ON THIS WIKI
Module:Util
Documentation for this module may be created at Module:Util/doc
local p = {}
local g = require("Module:Common")
-- expands a template for each value in a given comma-separated list
function p.mwExpandMulti(frame)
local frame, args = g.getFrameAndArgs(frame)
local out = ""
if g.isGiven(args.template) and g.isGiven(args.args) then
for arg in string.gmatch(args.args, "[^,]+") do
out = out .. frame:expandTemplate{title=args.template, args={arg}}
end
end
return out
end
-- returns a string with category definitions for a semicolon-separated list of
-- category names
function p.mwMultiCat(frame)
local categories = frame.args[1]
local out = ""
if g.isGiven(categories) then
for cat in string.gmatch(categories, "[^;]+") do
out = out .. "[[Category:" .. cat .. "]] "
end
end
return out
end
-- returns a string with SMW property definitions for a property and a
-- semicolon-separated list of values
function p.mwMultiPropVals(frame)
local prop = frame.args[1]
local vals = frame.args[2]
local excludes = frame.args[3]
local excludeSet = {}
if g.isGiven(excludes) then
for val in string.gmatch(vals, "[^;]+") do
excludeSet[val] = true
end
end
local out = ""
if g.isGiven(vals) then
for val in string.gmatch(vals, "[^;]+") do
if excludeSet[val] == nil then
out = out .. g.smwProp(prop, val, "") .. " "
end
end
end
return out
end
return p
Twitter Feed
Warning: file_get_contents(/srv/common/): failed to open stream: No such file or directory in /var/www/html/skins/MMWiki/SkinMMWiki.php on line 392
Discussion
To discuss the topics on this wiki, you can visit our community forums!