-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The first parameter of block helpers (documentation) #12
Comments
Hey, good catch in the docs. Yehuda and I changed things right before announcing handlebars and didn't update the docs correctly, it seems. The first parameter is the context that is handled to the block (it's the parameter for helpers used with expressions as well). So, for example, if you had a helper named link:
And data like:
You could then use it in a template as:
|
Ok, that makes sense — thanks. I see you updated the Readme to say that the context parameter is null when none is passed in the template; however, the current behaviour seems to be that actually the hash at the current context is passed (like |
I just updated the docs. I was working from memory when I answered you and I remembered it wrong. So if no argument is given the current context will be passed as the first argument (basically equivalent to passing |
Ok, that is clear. Thanks very much! :) |
Add passing test for compiling SVG elements
I'm currently struggling to see the purpose of the first parameter of block helper functions (
context
). Could you explain how it differs fromthis
?A brief look at the code suggests that what a block helper calls
this
is actually calledcontext
orwrappedContext
internally, and what a block helper callscontext
is calledproxy
internally. (In theaddBlock
andhandleBlock
methods.) Beyond that I find it gets a bit involved. A few experiments suggest that they behave quite similarly, with subtle differences (e.g. issue #11 doesn't occur withthis
replaced bycontext
).Moreover, the README suggests that:
...which is not the case, unless I misunderstand the sentence. Should that be more something like:
Hope you could shed some light on the intentions behind
this
vs.context
. Thanks!The text was updated successfully, but these errors were encountered: