mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-27 12:04:21 +00:00
Added chunkname
param to lovebird.template() and use of
This commit is contained in:
parent
2d15afd663
commit
c01eadea6b
@ -379,18 +379,19 @@ function lovebird.init()
|
|||||||
end
|
end
|
||||||
-- Compile page templates
|
-- Compile page templates
|
||||||
for k, page in pairs(lovebird.pages) do
|
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
|
end
|
||||||
lovebird.inited = true
|
lovebird.inited = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lovebird.template(str, params)
|
function lovebird.template(str, params, chunkname)
|
||||||
params = params and ("," .. params) or ""
|
params = params and ("," .. params) or ""
|
||||||
local f = function(x) return string.format(" echo(%q)", x) end
|
local f = function(x) return string.format(" echo(%q)", x) end
|
||||||
str = ("?>"..str.."<?lua"):gsub("%?>(.-)<%?lua", f)
|
str = ("?>"..str.."<?lua"):gsub("%?>(.-)<%?lua", f)
|
||||||
str = "local echo " .. params .. " = ..." .. str
|
str = "local echo " .. params .. " = ..." .. str
|
||||||
local fn = assert(loadstring(str))
|
local fn = assert(loadstring(str, chunkname))
|
||||||
return function(...)
|
return function(...)
|
||||||
local output = {}
|
local output = {}
|
||||||
local echo = function(str) table.insert(output, str) end
|
local echo = function(str) table.insert(output, str) end
|
||||||
|
Loading…
Reference in New Issue
Block a user