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

Template not found when I using extends in my template #28

Open
hungtcs opened this issue Jan 11, 2018 · 3 comments
Open

Template not found when I using extends in my template #28

hungtcs opened this issue Jan 11, 2018 · 3 comments

Comments

@hungtcs
Copy link

hungtcs commented Jan 11, 2018

This is my project tree view:

src
`-- templates
    |-- _layouts
    |   `-- login.layout.njk
    `-- pages
        `-- login.njk

And the login.njk

{% extends "../_layouts/login.layout.njk" %}
{% block main_content %}
  login page!
{% endblock %}
@dmoosocool
Copy link

Emm. got same..
image

and my task..

exports.njk = function njk(){
  return gulp.src(GULPCONFIG.filepath.njk, { base: GULPCONFIG.filepath.dev })
    .pipe(nunjucks.compile())
    .pipe(through.obj((chunk, enc, callback) => {
      chunk.extname = '.html';
      return callback && callback(null, chunk);
    }))
    .pipe(gulp.dest(GULPCONFIG.filepath.dist));
};

how to fixed it?

@alkorlos
Copy link
Contributor

Duplicate #14

Unfortunately in gulp-nunjucks is no option for relative path to templates.

@slavafomin
Copy link

The gulp-nunjucks-render has a better API and allows to specify the path from which all the templates will be resolved:

import gulpNunjucksRender from 'gulp-nunjucks-render';

export function buildTemplates() {
  return src('templates/**/*.nj')
    .pipe(gulpNunjucksRender({
      path: 'templates/',
    }))
    .pipe(dest('dist/'))
  ;
}

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

4 participants