Skip to content

Commit

Permalink
Added hardcoded locals
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Khan committed Oct 18, 2011
1 parent f4becea commit f8a1739
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/coffeekup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ coffeekup.compile = (template, options = {}) ->
else hardcoded_locals += "var #{k} = #{JSON.stringify v};"

if compiler?
return compiler.compile template, options
return compiler.compile template, hardcoded_locals, options
template = "function(){#{template}}"

# Add a function for each tag this template references. We don't want to have
Expand Down
5 changes: 3 additions & 2 deletions src/compiler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ call_bound_func = (func) ->
parse_expr = (expr) ->
return parser.parse(expr)[1][0]

exports.compile = (source, options) ->
exports.compile = (source, hardcoded_locals, options) ->

ast = parser.parse source
w = uglify.ast_walker()
Expand Down Expand Up @@ -95,7 +95,8 @@ exports.compile = (source, options) ->
beautify: true
indent_level: 2

code = skeleton + compiled
# Main function assembly.
code = hardcoded_locals + skeleton + compiled
code += "return __ck.buffer.join('');"

return new Function 'data', code
Expand Down

0 comments on commit f8a1739

Please sign in to comment.