Module:Catnav: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
PetraMagna (talk | contribs) (Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} function p.main(frame) local args = getArgs(frame) return p._main(args) end function p.make_cat(name) return "" .. name .. "" end function p._main(args) local length = 0 for k, v in pairs(args) do length = length + 1 end local result = "" if length == 1 then result = p.cat(args[1]) elseif length == 2 then result = p.make_link(args[1]) .. " and " .. p.make_link(...") |
PetraMagna (talk | contribs) mNo edit summary |
||
Line 7: | Line 7: | ||
end |
end |
||
function p. |
function p.make_link(name) |
||
return "[[:Category:" .. name .. "|" .. name .. "]]" |
return "[[:Category:" .. name .. "|" .. name .. "]]" |
||
end |
end |
||
Line 17: | Line 17: | ||
end |
end |
||
local result = "" |
local result = "" |
||
⚫ | |||
if length == 1 then |
|||
result = p. |
result = result .. p.make_link(value) |
||
if key ~= length then |
|||
result = |
result = result .. " > " |
||
else |
|||
⚫ | |||
result = result .. p.make_link(value) |
|||
if key ~= length then |
|||
result = result .. " > " |
|||
end |
|||
end |
end |
||
end |
end |
Latest revision as of 21:42, 27 May 2024
Documentation for this module may be created at Module:Catnav/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p.make_link(name)
return "[[:Category:" .. name .. "|" .. name .. "]]"
end
function p._main(args)
local length = 0
for k, v in pairs(args) do
length = length + 1
end
local result = ""
for key, value in pairs(args) do
result = result .. p.make_link(value)
if key ~= length then
result = result .. " > "
end
end
return result
end
return p