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

Nunjucks extends, file not found #43

Closed
rawberg opened this issue Aug 23, 2015 · 4 comments
Closed

Nunjucks extends, file not found #43

rawberg opened this issue Aug 23, 2015 · 4 comments

Comments

@rawberg
Copy link

rawberg commented Aug 23, 2015

Having trouble getting template inheritance to work with Nunjucks. Tried putting both templates in the layouts directory and also defining partials as "layouts" but always get "file not found" error for the template being inherited.

Consolidate.js suggets this loader option, not sure how that would work in the context of metalsmith?

@rawberg
Copy link
Author

rawberg commented Aug 23, 2015

turns out the path to the template being extended is relative to the the root of the project.

{% extends "layouts/master.html" %}   // works
{% extends "master.html %} // does not work

"metalsmith-layouts" {
    "engine": "nunjucks"
}

@ismay
Copy link
Member

ismay commented Aug 29, 2015

turns out the path to the template being extended is relative to the the root of the project.

Yeah the implementations differ from engine to engine.

Consolidate.js suggets this loader option, not sure how that would work in the context of metalsmith?

Basically any option that's passed to metalsmith-layouts that it doesn't recognise is passed on to consolidate. So you can use that, and you can also configure a global instance of nunjucks (var nunjucks = require('nunjucks'); and that seems to be picked up by consolidate as well (even though the requires option is the official way of configuring an engine).

@ismay ismay closed this as completed Aug 29, 2015
@micahgodbolt
Copy link
Contributor

Does anyone have an explanation of how to resolve this issue? I'm having the same problem with extends and haven't had any luck with any of the suggestions mentioned here.

@micahgodbolt
Copy link
Contributor

Ah! Finally found it. The directory has to be set like this:

var nunjucks = require('nunjucks');
nunjucks.configure('./templates', {watch: false})

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

3 participants