canjs / can-stache

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

Can't call partials stored in LetContext as Call Expressions #649

Closed phillipskevin closed 5 years ago

phillipskevin commented 5 years ago

This works:

    {{< foo }}
      This is foo
    {{/ foo }}

    <p>{{ scope.templateContext.partials.foo() }}</p>

...and this works:

    {{< foo }}
      This is foo
    {{/ foo }}

    {{ let bar = scope.templateContext.partials.foo }}

    <p>{{ bar "baz" }}</p>

...but this doesn't work:

    {{< foo }}
      This is foo
    {{/ foo }}

    {{ let bar = scope.templateContext.partials.foo }}

    <p>{{ bar() }}</p>

In this case, the partial is called, but not rendered. I'm not sure why.

justinbmeyer commented 5 years ago

Probably because the render function is inside an observable.

justinbmeyer commented 5 years ago

https://github.com/canjs/can-stache/blob/master/expressions/call.js#L75