From c01eadea6b2622c3044633beeff2c8a2750d2708 Mon Sep 17 00:00:00 2001 From: rxi Date: Tue, 15 Apr 2014 12:37:42 +0100 Subject: [PATCH] Added `chunkname` param to lovebird.template() and use of --- lovebird.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lovebird.lua b/lovebird.lua index 838b81e..5d44c2b 100644 --- a/lovebird.lua +++ b/lovebird.lua @@ -379,18 +379,19 @@ function lovebird.init() end -- Compile page templates for k, page in pairs(lovebird.pages) do - lovebird.pages[k] = lovebird.template(page, "lovebird, req") + lovebird.pages[k] = lovebird.template(page, "lovebird, req", + "pages." .. k) end lovebird.inited = true end -function lovebird.template(str, params) +function lovebird.template(str, params, chunkname) params = params and ("," .. params) or "" local f = function(x) return string.format(" echo(%q)", x) end str = ("?>"..str.."(.-)<%?lua", f) str = "local echo " .. params .. " = ..." .. str - local fn = assert(loadstring(str)) + local fn = assert(loadstring(str, chunkname)) return function(...) local output = {} local echo = function(str) table.insert(output, str) end