Module:Sandbox/Eelworm/Junctions

local p = {} local getArgs = require ('Module:Arguments').getArgs;

function p._junctions(args, frame) local ret = '{| class="wikitable"\n|+\n!header1\n!header2\n' local largs = {} local tot = {} local gargs = {} if (args["old"] or "no") == "yes" then gargs["old"] = "yes" ret = ret .. "!old exit number\n" end for _,arg in pairs(args) do		if (arg == "|-") then table.insert(tot, largs) largs = {} else table.insert(largs, arg) end end table.insert(tot, largs) for _,tab in pairs(tot) do		for k,v in pairs(gargs) do			tab[k] = v		end ret = ret .. "|-\n|" .. frame:expandTemplate{ title = "User:Eelworm/Junction", args = tab} .. "\n" end ret = ret .. "|}\n" mw.log(ret) return ret end

function p.junction(frame) local pargs = getArgs(frame:getParent) local args = getArgs(frame) local ret = "" ret = ret .. args[1] if args["old"] == "yes" then ret = ret .. "\n|" .. ret .. "\n|" .. ret else ret = ret .. "\n|" .. ret end return ret end

function p.junctions(frame) local args = getArgs(frame) return p._junctions(args, frame) end

return p