-
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
Helpers called from with-in @partial-blocks do not have access to the root data. #1445
Comments
Hi and thanks for the thorough research. I'm sorry, if I have introduced a breaking change. If there is a way to go back to the old behaviour without breaking any fixes made in the meantime, this should be done. |
I have stripped down your examples a little, in order to get a minimal test case The data-frame goes missing somewhere. This should definitely not be the case. |
I think I found the problem: Partial-blocks are called with Change this and your example seems to be much more compatible and much less breaking. It is unfortunate, that this code works at all, or at least pretends to do so. I only found the reason, because my test-case worked and I started to compare it to your example. Here is the reason why the result is so similar to the partial-block invocation: The compiled partial-block is added to the current Please check if this is helpful for you. |
Released in 4.0.12 |
Issue: Helpers called from with-in @partial-blocks do not have access to the root data.
When calling a registered helper from with-in an @partial-block starting from v4.0.7 you no longer have access to the root data that was supplied in v4.0.6.
I believe there was a breaking change added in v4.0.7 that changed how the
@partial-blocks
are being processed in side of lib/handlebars/runtime.js:invokePartial. This change has been compounded in later commits and bug releases because the data object has changed between v4.0.7 and v4.0.11 .Root of issue believed to come from the fix added for issue #1252
Objects passed to the helper function:
v4.0.6
v4.0.11
JS Fiddle Cases by Handlebar version:
^^ Notice the difference in the context between v4.0.6 and v4.0.11 for
Test case 2
Was able to reproduce the issue with compiled templates. But I think that the lambda method adds complexity to this issue, since I was seeing in the call stack it was being called up in the call stack (
lambda -> partialBlockWrapper -> prog -> 9 -> helper.testHelper.call(...)
). In this case when partialBlockWrapper is called there will be no context or options argument passed, which results in the v4.0.11 argument (see the v4.0.11 data above) being passed to thehelper.testHelper
.The text was updated successfully, but these errors were encountered: