tildeio / htmlbars

A variant of Handlebars that emits DOM and allows you to write helpers that manipulate live DOM nodes
MIT License
1.61k stars 193 forks source link

fixes emberjs/ember.js#12506 #448

Open Saranya-Raaj opened 8 years ago

Saranya-Raaj commented 8 years ago

fixes emberjs/ember.js#12506

rwjblue commented 8 years ago

This seems correct to me.

@mixonic / @mmun - Any objections?

stefanpenner commented 8 years ago

we should be careful about perf

chadhietala commented 8 years ago

I second Stef's concern, get can be called a pretty significant amount of times.

screen shot 2016-02-02 at 11 45 29 pm
mmun commented 8 years ago

We already lookup helpers for curlies that appear outside of attributes: https://github.com/tildeio/htmlbars/blob/master/packages/htmlbars-runtime/lib/hooks.js#L698. Doing it for attributes as well is the correct thing to do.

That said, I don't like this particular implementation. get should not be looking up helpers. In {{foo bar}}, bar is never a helper, but with this implementation we would be checking if it was. Instead, we should add an ambiguous hook that delegates get or subexpr depending on whether the path resolves to a helper or not. The ambiguous hook would be called whenever there was a {{foo}} in the template (whether in content or in an attribute). {{foo.bar}} should not trigger the ambiguous hook however.