Module:Category handler: Difference between revisions
m a semicolon |
refactor; try to enter category names one by one as unnamed params |
||
| Line 135: | Line 135: | ||
return result | return result | ||
end | end | ||
-- Wrapper for templates calling via #invoke | -- Wrapper for templates calling via #invoke | ||
function p.category_handler(frame) | function p.category_handler(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local excluded_ns_unparsed = args["excluded_ns"] or "" | local excluded_ns_unparsed = args["excluded_ns"] or "" | ||
local suffixes_unparsed = args["suffixes" ] or "" | local suffixes_unparsed = args["suffixes" ] or "" | ||
| Line 146: | Line 144: | ||
-- Parse categories | -- Parse categories | ||
-- Categories are entered using unnamed params | |||
local cats = {} | local cats = {} | ||
for _, cat in ipairs(args) do | |||
cat = mw.text.trim(cat) | |||
if cat ~= "" then | |||
table.insert(cats, cat) | |||
end | |||
end | |||
--[[ | |||
for cat in mw.text.gsplit(cats_unparsed, "[;\n]") do | for cat in mw.text.gsplit(cats_unparsed, "[;\n]") do | ||
cat = mw.text.trim(cat) | cat = mw.text.trim(cat) | ||
| Line 153: | Line 160: | ||
end | end | ||
end | end | ||
]]-- | |||
-- Parse excluded namespaces | -- Parse excluded namespaces | ||