Module:In category
![]() | This module depends on the following other modules: |
Implements {{in category}}.
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local compressSparseArray = require('Module:TableTools').compressSparseArray
local function ucfirst(text)
return string.upper(string.sub(text, 1, 1)) .. string.sub(text, 2)
end
local function in_category(args)
local categories = compressSparseArray(args)
for i = 1, #categories do
categories[i] = '[[:Category:' .. ucfirst(categories[i]) .. ']]'
end
local cat_text = categories[1] or ''
if #categories > 1 then
cat_text = table.concat(categories, ', ', 1, #categories - 1) .. ' and ' .. categories[#categories]
end
return ':\'\'This template will categorize into ' .. cat_text .. '.\'\''
end
function p.in_category(frame)
return in_category(getArgs(frame))
end
return p