handlers.lua

changeset 2
3975fa5ed630
child 3
b2df1b3f2c83
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/handlers.lua	Sat Sep 12 21:27:57 2009 +0300
@@ -0,0 +1,38 @@
+
+module("handlers", package.seeall)
+
+require("handlers.render")
+require("handlers.copy")
+require("handlers.ignore")
+
+local available={
+    { pattern = "%.page$", handler = handlers.render},
+    { pattern = "",        handler = handlers.copy},
+}
+
+
+function find(f)
+    for _, h in ipairs(available) do
+        if string.match(h.pattern, f) 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