canjs / can-stache

Live binding handlebars templates
https://canjs.com/doc/can-stache.html
MIT License
10 stars 13 forks source link

Helper called without trailing "()" does not warn #638

Closed mjstahl closed 5 years ago

mjstahl commented 6 years ago

TL;DR https://codepen.io/kphillips86/pen/XyxYgo

Assuming a helper:

stache.addHelper('helloWorld', function helloWorld(options) { ... });

And a stache file that uses that helper:

{{#helloWorld}}
  <p>is rendered</p>
{{else}}
  <p>is NOT rendered
{{/helloWorld}}

helloWorld will not be executed, or is there a warning on the console that the helper should be called like helloWorld().

Also, oddly enough the "truthy" section of the condition is rendered.

chasenlehara commented 6 years ago

I think this is the expected behavior. My understanding is: stache is looking for helloWorld and it finds it (the helper is defined). The helper won’t be called (I think that was removed as of 4.x) and the truthy part will be rendered because helloWorld is defined.

chasenlehara commented 5 years ago

I’m closing this issue because I think it’s the expected behavior (see my comment above).

If I’m wrong, please feel free to reopen this. 😊