tbranyen / combyne

A template engine that works the way you expect.
MIT License
144 stars 19 forks source link

Allow templates to loop over "this" #6

Closed incompl closed 10 years ago

incompl commented 13 years ago

var template = '{%each this%} {{name}} {%endeach%}'; var context = [{name:"Fred"}]; combyne(template, context).render();

would output "Fred"

tbranyen commented 13 years ago

I'm not sure about this one. this could be a property on a context object in which case, should that be used or should the whole object be used? I think the same goes for any name we could think of. I was thinking of only iterating the context object if you omitted all arguments to each. Doesn't feel quite right though.

incompl commented 13 years ago

Good point, you led me to notice that "this" is an invalid object key in handlebars. I wonder if there is a way to do this with a syntax that doesn't fight the context namespace.

incompl commented 13 years ago

I actually like the "each" by itself idea

tbranyen commented 10 years ago

Closed via a121a5535ff5a9b098aaeb8417c53acde67deed5