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

NJK crashes if component name is the same as the template name #99

Open
DaveBitter opened this issue Mar 1, 2019 · 2 comments
Open
Assignees
Labels

Comments

@DaveBitter
Copy link
Collaborator

The build process of NJK crashes if the component name is the same as the template name while using the component plugin.

Steps to reproduce:

  1. create a example template in templates/example/example.njk
  2. create a example component in components/example/example.njk
  3. load the example component in the example template file using the component plugin.
@DaveBitter DaveBitter added the bug label Mar 1, 2019
@colin-aarts
Copy link
Member

Nice catch, I'll check it out.

@colin-aarts colin-aarts self-assigned this Mar 1, 2019
@colin-aarts
Copy link
Member

It has to do with the fact that we configure multiple "entry points" in the nunjucks render call (for layouts, templates and components; html.js L29-31). It seems to try them in the specified order, which happens to have templates before components. It then finds a matching template with the same path as the component, causing an infinite loop and then a call stack overflow.

I've tried to be explicit in passing the full path to the {% component %} tag's render call, but it won't accept it. It seems like it needs to be relative to one of the previously provided entry points.

Quick fix for this scenario would be to switch the order of the templates and components entry point listing (tested; works) but I'm not sure if that won't cause other issues.

Thoughts, @mirabeau-nl/front-end-developers ?

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

No branches or pull requests

2 participants