Module:Sandbox: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
No edit summary
escape special character
Line 3: Line 3:
function p.get_appeal( frame )
function p.get_appeal( frame )


local appeal_name = string.gsub( frame.args.appeal , 'Appeal-', '' )
local appeal_name = string.gsub( frame.args.appeal , 'Appeal%-', '' )
local language = frame.args.language
local language = frame.args.language
local country = frame.args.country
local country = frame.args.country

Revision as of 20:11, 5 March 2019

Documentation for this module may be created at Module:Sandbox/doc

local p = {} -- p stands for package

function p.get_appeal( frame )

    local appeal_name = string.gsub( frame.args.appeal , 'Appeal%-', '' )
    local language = frame.args.language
    local country = frame.args.country

    local p1 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/' .. language .. '/' .. country )
    local p2 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/' .. language )
    local p3 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/en' )
    local p4 = mw.title.new( 'Template:Appeal/default/' .. language )

    if p1.exists then
        page = p1
    elseif p2.exists then
        page = p2
    elseif p3.exists then
        page = p3
    else
        page = p4
    end

    local expanded = frame:expandTemplate{ title = page, args = { } }

    return expanded
    
end

return p