Difference between revisions of "Module:Used by/Sandbox"
Line 5: | Line 5: | ||
end | end | ||
− | function | + | function p.classes(frame) |
local args = frame.args | local args = frame.args | ||
local count = 0 | local count = 0 | ||
Line 17: | Line 17: | ||
end | end | ||
end | end | ||
− | + | ||
− | + | local first = args.remove(0) | |
− | + | count = #args | |
− | + | if first == 'all' then | |
− | + | return common_string{'infobox-used-by-all'} | |
− | return common_string{'infobox-used-by-all'} | + | elseif first == 'all-except' then |
− | + | return common_string{'infobox-used-by-all-except-' .. count, unpack(args)} | |
− | + | else | |
− | + | return common_string{'infobox-used-by-' .. count, unpack(args)} | |
− | + | end | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
return p | return p |
Revision as of 06:18, 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 p.classes(frame) local args = frame.args local count = 0 for _ in pairs(args) do count = count + 1 end if count == 0 then args = frame:getParent().args for _ in pairs(args) do count = count + 1 end end local first = args.remove(0) count = #args if first == 'all' then return common_string{'infobox-used-by-all'} elseif first == 'all-except' then return common_string{'infobox-used-by-all-except-' .. count, unpack(args)} else return common_string{'infobox-used-by-' .. count, unpack(args)} end end return p