handlers.lua

Wed, 31 Jan 2018 19:51:10 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 31 Jan 2018 19:51:10 +0000
changeset 15
82d254b8f01e
parent 7
038275cd92ed
child 26
77cd7b8fb6a6
permissions
-rw-r--r--

added markdown: true/false meta-tag


--@module handlers

local handlers={}

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

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


function handlers.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 handlers.choose(f, env)
    cached[f] = handlers.find(f)
end

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

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

return handlers

mercurial