FANDOM


local Template = {}
 
function list(args, form)
    local keys = {}
    for k, v in pairs(args) do
        table.insert(keys, ''..k)
    end
    table.sort(keys)
 
    local res = {}
    for _, v in ipairs(keys) do
        table.insert(res, mw.ustring.format(form, mw.text.nowiki(v), mw.text.nowiki(args[v])))
    end
 
    return table.concat(res, '\n')
end
function Template.showParameters(frame)
    return list(arguments(mergeFrames(frame, frame:getParent())), '<pre class="tempalte-parameter" data-param="%s">%s</pre>')
end
function Template.hiddenParameters(frame)
    return list(arguments(mergeFrames(frame, frame:getParent())), '<div class="tempalte-parameter" data-param="%s" data-value="%s" ></div>')
end
function mergeFrames(frame, parent) -- Allows to overwrite with parameters from the template that invoked the module
    local args = {}
    if frame then
        for k,v in pairs(frame.args) do
            args[k] = v
        end
    end
    if parent then
        for k,v in pairs(parent.args) do
            args[k] = v
        end
    end
    return args
end
function arguments(origArgs)
    local args = {}
    for k, v in pairs(origArgs) do
        if type(v) == 'string' then v = mw.text.trim(v) end
        if v ~= '' then args[k] = v end
    end
    return args
end
return Template

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.