Sun, 13 Sep 2009 22:22:47 +0300
Improvements
2 | 1 | |
2 | module("handlers", package.seeall) | |
3 | ||
4 | require("handlers.render") | |
5 | require("handlers.copy") | |
6 | require("handlers.ignore") | |
7 | ||
8 | local available={ | |
3 | 9 | { pattern = "%.lg$", handler = handlers.render}, |
10 | { pattern = "", handler = handlers.copy}, | |
2 | 11 | } |
12 | ||
13 | ||
14 | function find(f) | |
15 | for _, h in ipairs(available) do | |
3 | 16 | if string.match(f, h.pattern) then |
2 | 17 | return h.handler |
18 | end | |
19 | end | |
20 | return handlers.ignore | |
21 | end | |
22 | ||
23 | local cached={} | |
24 | ||
25 | function choose(f, env) | |
26 | cached[f] = find(f) | |
27 | end | |
28 | ||
29 | -- load | |
30 | function phase1(f, env) | |
31 | return cached[f].phase1(f, env) | |
32 | end | |
33 | ||
34 | -- write | |
35 | function phase2(f, env) | |
36 | return cached[f].phase2(f, env) | |
37 | end | |
38 |