handlers.lua

Sun, 07 May 2017 20:02:53 +0100

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 07 May 2017 20:02:53 +0100
changeset 6
219d7a7304f8
parent 4
4cb0d1dbc65b
child 7
038275cd92ed
permissions
-rw-r--r--

5.3 updates


module("handlers", package.seeall)

require("handlers.render")
require("handlers.copy")
require("handlers.ignore")

local available={
    { pattern = "%.lg$", handler = handlers.render},
    { pattern = "%.note$", handler = handlers.ignore},
    { pattern = "",      handler = handlers.copy},
}


function find(f)
    for _, h in ipairs(available) do
        if string.match(f, h.pattern) then
            return h.handler
        end
    end
    return handlers.ignore
end

local cached={}

function choose(f, env)
    cached[f] = find(f)
end

-- load
function phase1(f, env)
    return cached[f].phase1(f, env)
end

-- write
function phase2(f, env)
    return cached[f].phase2(f, env)
end

mercurial