fixes for lua 5.2
This commit is contained in:
parent
08449cbc86
commit
b8b91215f1
|
@ -325,7 +325,7 @@ local default_mt = {
|
|||
__index = function(self, n)
|
||||
local cf = self.context[n]
|
||||
if cf == nil then
|
||||
return getfenv(0)[n]
|
||||
return self.__genv[n]
|
||||
end
|
||||
return cf
|
||||
end
|
||||
|
@ -339,7 +339,7 @@ local dump_ret = function(acc)
|
|||
end
|
||||
|
||||
local loads
|
||||
if not loadstring then
|
||||
if not setfenv then
|
||||
loads = function(str, env)
|
||||
return assert(load(str, str, "t", env))
|
||||
end
|
||||
|
@ -352,7 +352,8 @@ end
|
|||
M.compile = function(str)
|
||||
-- environment is nicely encapsulated...
|
||||
local denv = setmetatable({
|
||||
template = M, blocks = {}, escape = escapes
|
||||
template = M, blocks = {}, escape = escapes,
|
||||
__genv = getfenv and getfenv(1) or _ENV
|
||||
}, default_mt)
|
||||
local f = loads(parse(lex_new(make_stream(str))), denv)
|
||||
return function(ctx, write)
|
||||
|
|
Loading…
Reference in New Issue