sstephenson / eco

Embedded CoffeeScript templates
MIT License
1.71k stars 70 forks source link

local variables in template? #23

Closed jots closed 13 years ago

jots commented 13 years ago

will this ever be possible:

name="fred" eco.render "<%= name %>"

currently I have a lot of: @name = name for the sole purpose of getting them to render in the template.

sstephenson commented 13 years ago

No, you always need to pass a context object to eco.render. CoffeeScript's object literal syntax can help:

name = "Fred"
eco.render "<%= @name %>", {name}