This commit is contained in:
leaf corcoran
2014-02-19 00:07:08 -08:00
parent 5fc37e17bd
commit a0aad3e29e

View File

@@ -69,7 +69,7 @@ do
end end
end, end,
header = function(self) header = function(self)
return self:push("local _b, _b_i, _tostring, _concat, _escape = ...\n") return self:push("local _tostring, _escape, _b, _b_i = ...\n")
end, end,
footer = function(self) footer = function(self)
return self:push("return _b") return self:push("return _b")
@@ -297,13 +297,10 @@ do
end end
return fn return fn
end, end,
run = function(self, fn, env, buffer) run = function(self, fn, env, buffer, i, ...)
if env == nil then if env == nil then
env = { } env = { }
end end
if buffer == nil then
buffer = { }
end
local combined_env = setmetatable({ }, { local combined_env = setmetatable({ }, {
__index = function(self, name) __index = function(self, name)
local val = env[name] local val = env[name]
@@ -313,8 +310,12 @@ do
return val return val
end end
}) })
if not (buffer) then
buffer = { }
i = 0
end
setfenv(fn, combined_env) setfenv(fn, combined_env)
return fn(buffer, #buffer, tostring, concat, html_escape) return fn(tostring, html_escape, buffer, i, ...)
end, end,
compile_to_lua = function(self, str, ...) compile_to_lua = function(self, str, ...)
local success, err = self:parse(str) local success, err = self:parse(str)
@@ -345,7 +346,7 @@ do
r:push(chunk[2], "\n") r:push(chunk[2], "\n")
elseif "=" == _exp_0 or "-" == _exp_0 then elseif "=" == _exp_0 or "-" == _exp_0 then
r:increment() r:increment()
r:mark() r:mark(chunk[3])
r:assign() r:assign()
if t == "=" and self.html_escape then if t == "=" and self.html_escape then
r:push("_escape(_tostring(", chunk[2], "))\n") r:push("_escape(_tostring(", chunk[2], "))\n")