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

Partial template recursion throws Error #1245

Closed
alexey2baranov opened this issue Aug 24, 2016 · 1 comment
Closed

Partial template recursion throws Error #1245

alexey2baranov opened this issue Aug 24, 2016 · 1 comment

Comments

@alexey2baranov
Copy link

alexey2baranov commented Aug 24, 2016

Hello! Hire is my template with partial. Can you help me to get him correct

**Node.handlebars**

<div>
    {{text}}
    {{> Node child }}
</div>

As you can see Node shows himself and next shows this child with partial(> Node partial registered by Handlebars.registerPartial("Node", Handlebars.templates.Node)). In short > Node references himself to show his child

Now when I run this template

Handlebars.templates.Node({
    text: "parent node text",
    child:{
        text: "child text"
    }
});

I would like to see this HTML

<div>parent text
<div>child text</div>
</div>

But get Error

/home/alexey2baranov/htdocs/kp-client/src/templates.js:6
+ container.escapeExpression(((helper = (helper = helpers.text || (depth0 != null ? depth0.text : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"text","hash":{},"data":data}) : helper)))
^

RangeError: Maximum call stack size exceeded
at Object.templates.Node.template.main (/home/alexey2baranov/htdocs/kp-client/src/templates.js:6:224)
at main (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
at ret (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
at Object.invokePartial (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
at Object.invokePartialWrapper as invokePartial
at Object.templates.Node.template.main (/home/alexey2baranov/htdocs/kp-client/src/templates.js:8:28)
at main (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
at ret (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
at Object.invokePartial (/home/alexey2baranov/htdocs/kp-client/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
at Object.invokePartialWrapper as invokePartial

@alexey2baranov
Copy link
Author

solved by {{#if}}

{{text}} {{#if child}} {{> Node child }} {{/if}}

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

No branches or pull requests

1 participant