Hey,
Just wanted to flag some behaviour which I think is quite weird in meteor's extension to allows nested handlebars calls.
Suppose I am rendering with the data context:
{
foo: function(){ return 'foo'; },
bar: 'bar';
}
then we have the following behaviours:
{{ helper foo }} === {{ helper(data.foo()) }} === {{ helper('foo') }}. [1]
{{ helper foo bar }} === {{ helper(data.foo(data.bar)) }} == {{ helper('foo') }}. [2]
{{ helper bar foo }} === {{ helper(data.bar, data.foo) }} == {{ helper('bar', function…) }} [3]
Now,
[1] is perfect
[2] _does_ make sense when foo is an helper function defined either by
a) Handlebars.registerHelper OR
b) Template.X.foo =
but, imho doesn't make much sense in this case.
[3] doesn't really make sense (to me) at all. At the very least why is helper not passed in the result of foo() ?
What this means practically is that if I want to pass in the result of functions to a helper, I need to
A) do a lot of boilerplate in my helpers like:
if (typeof arg == 'function')
arg = arg.call(this)
B) ensure that I only pass one function argument to a helper and that it's not the first argument. This is obviously a bit of an issue.
I don't really have a good suggestion on how it _should_ work, maybe some extra syntax is needed to differentiate what you are trying to do when nesting calls. Has anyone else run into this? Any suggestions?
Tom