Module:Routelist row

This is an old revision of this page, as edited by Happy5214 (talk | contribs) at 11:31, 27 February 2013 (Allowing future row color). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {
    mw = require("Module:mw"),
    lang = mw.getContentLanguage()
}

function p.rowcolor(frame)
    --This function determines if this is a future route, present route, or decommissioned route, and colors the row appropriately.
    
    --Import parameters from template
    local established = frame.args[1]
    local decommissioned = frame.args[2]

    if p.lang:formatDate('Y-m-d') < established then --this is a future route
        return "|- style=\"background-color:#ffdead;\" title=\"Future route\"\n"
    elseif decommissioned ~= '0' then --this is a decommissioned route
        return '|- style=\"background-color:#d3d3d3;\" title=\"Former route\"\n'
    else --this is a normal route
        return '|- \n'
    end
end

function p.termini(frame)
    --This function determines if this is a beltway or not, and displays the termini columns appropriately.
    
    --Import parameters from template
    local beltway = frame.args[1]
    local terminus_a = frame.args[2]
    local terminus_b = frame.args[3]

    --The template passes this function the string "0" if {{{beltway}}} is not specified by the template user. 
    if beltway ~= '0' then
        return "|colspan=2 align=center|" .. beltway
    else
       return '|' .. terminus_a .. '||' .. terminus_b
    end
end

return p