expose _G

This commit is contained in:
leaf corcoran
2013-10-24 00:07:51 -07:00
parent 79ad17f9f1
commit edeae43cd5
2 changed files with 13 additions and 1 deletions

View File

@@ -132,7 +132,12 @@ class Parser
fn = assert load(code_fn, name)
(env={}) ->
setfenv fn, env
combined_env = setmetatable {}, __index: (name) =>
val = env[name]
val = _G[name] if val == nil
val
setfenv fn, combined_env
fn tostring, concat, html_escape
-- generates the code of the template

View File

@@ -78,6 +78,13 @@ This is my message to <%= [=[oh yeah %>"]=] %>]]
"
}
-- should have access to _G
{
""
"<% assert(true) %>"
{ hello: "world" }
}
}
for case in *cases