Module:Dependencies
From COMP15212 Wiki
This module adds dependencies to Semantic MediaWiki and prints the dependencies on screen. In the future it will print the dependencies in a prettier way. This module needs to be called directly rather than through a template because of its use of a variable number of arguments.
local p = {}
p.add = function(frame)
local output = "{| class=dependstable\n"
output = output .. "! Depends on \n| "
--[[ Each argument is a pair of string,int where the string is the name of the article being depended on
and int is the strength of the dependency]]
local hasDep = false
for i, v in ipairs(frame.args) do
local spliterator = (v..","):gmatch("(.-),")
local dependency = spliterator()
local strength = spliterator()
frame:expandTemplate{ title = 'SetDependency', args = { dependency, strength, tostring(mw.title.getCurrentTitle().fullText) } }
output = output .. "[[".. dependency .."]] • "
hasDep = true
end
if hasDep then
output = string.sub(output, 0, -5)
else
output = output .. "This article has no dependencies."
end
output = output .. " \n|}"
return output
end
return p