Skip to content
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

Using @partial-block twice in a template not possible #1252

Closed
Dangoo opened this issue Sep 21, 2016 · 4 comments · Fixed by renovatebot/renovate#194
Closed

Using @partial-block twice in a template not possible #1252

Dangoo opened this issue Sep 21, 2016 · 4 comments · Fixed by renovatebot/renovate#194

Comments

@Dangoo
Copy link

Dangoo commented Sep 21, 2016

I discovered that my issue with #1185 is caused by including the @partial-block twice inside a template like this:

template.hbs

<p>
    Me: "{{> @partial-block }}", <br />
    Echo: "{{> @partial-block }}"
</p>

demo.hbs

<div>
    {{#> template}}
        Hello echo!
    {{/template}}
</div>

Currently no possibility to check, but haven't touched the code and with with v4.0.3 it seemed to work, however after commit 7535e48 it produces the following console output:

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: The partial @partial-block could not be found
    at Object.invokePartial (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:255:11)
    at Object.invokePartialWrapper [as invokePartial] (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:65:39)
    at Object.eval (eval at createFunctionContext (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:252:23), <anonymous>:14:28)
    at main (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:170:32)
    at Object.ret (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:12)
    at Object.lsg-demo-section (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:467:21)
    at Object.invokePartialWrapper [as invokePartial] (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:69:46)
    at eval (eval at createFunctionContext (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:252:23), <anonymous>:5:31)
    at prog (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/runtime.js:206:12)
    at execIteration (<PROJEKT_ROOT>/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:42:19)

/cc @lawnsea

@nknapp
Copy link
Collaborator

nknapp commented Dec 30, 2016

I can confirm that it works with 4.0.3 and 4.0.4, but not in 4.0.5 and 4.0.6

@nknapp
Copy link
Collaborator

nknapp commented Dec 30, 2016

The following functions are called before the exception occurs:

With the template being {{#> dude}}success{{/dude}}
and the partial dude being {{> @partial-block }} {{> @partial-block }}
the function invokePartialWrapper is called with the following options.name and options.data:

invokePartialWrapper(
    options.name=dude, 
    options.data={ root: {} }
)
invokePartialWrapper(
    options.name=@partial-block,
    options.data={ root: {}, _parent: { root: {} }, 'partial-block': { [Function: prog] program: 1, depth: 0, blockParams: 0 } }
)
invokePartialWrapper(
    options.name=@partial-block
    options.data={ root: {}, _parent: { root: {} }, 'partial-block': [Function: noop] }
)

The last invocation has options.data['partial-block'] === noop and that seems to be the problem.

nknapp added a commit that referenced this issue Jan 1, 2017
This fix treats partial-blocks more like closures and uses the closure-context of
the "invokePartial"-function to store the @partial-block for the partial.
nknapp added a commit that referenced this issue Feb 14, 2017
Fixes #1252
- This fix treats partial-blocks more like closures and uses the closure-context of
  the "invokePartial"-function to store the @partial-block for the partial.
- Adds a tes for the fix
@nknapp nknapp closed this as completed in 5a164d0 Feb 17, 2017
@Dangoo
Copy link
Author

Dangoo commented Feb 17, 2017

Nice to hear, thanks @nknapp! Any ideas when the next version containing this will ship?

@nknapp
Copy link
Collaborator

nknapp commented Feb 17, 2017

I can't do that myself (I don't have publish rights for Handlebars on the various registries).

I'll open an issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants