Difference between revisions of "Module:Used by/Sandbox"
Line 20: | Line 20: | ||
function p.classes(frame) | function p.classes(frame) | ||
− | local args = | + | local args = get_args(frame) |
local first = args.remove(1) | local first = args.remove(1) |
Revision as of 06:30, 18 March 2023
Documentation for this module may be created at Module:Used by/Sandbox/doc
local p = {} function common_string(args) return mw.getCurrentFrame():expandTemplate{title='Common string', args=args} end function get_args(frame) local args = {} for _, arg in ipairs(frame.args) do args.insert(arg) end if #args > 0 then return args end for _, arg in ipairs(frame:getParent().args) do args.insert(arg) end return args end function p.classes(frame) local args = get_args(frame) local first = args.remove(1) if first == 'all' then return common_string{'infobox-used-by-all'} elseif first == 'all-except' then return common_string{'infobox-used-by-all-except-' .. #args, unpack(args)} else return common_string{'infobox-used-by-' .. #args, unpack(args)} end end return p