Module:Used by/Sandbox

From Team Fortress Wiki
< Module:Used by
Revision as of 03:19, 18 March 2023 by Darkid (talk | contribs) (Testing simplifications)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 = frame.args
    if #args == 0 then
        args = frame:getParent().args
    end
    return args
end

function p.all(frame)
    return common_string{'infobox-used-by-all'}
end

function p.all_except(frame)
    local args = get_args(frame)
    assert(#args >= 1) -- Must provide at least one "except" class
    assert(#args <= 2) -- Dictionary strings only support up to two exceptions
    return common_string{'infobox-used-by-all-except-' .. #args, unpack(args)}
end

function p.classes(frame)
    local args = get_args(frame)
    assert(#args >= 1) -- Must provide at least one class
    assert(#args <= 5) -- Dictionary strings only support up to five classes
    return common_string{'infobox-used-by-' .. #args, unpack(args)}
end

return p