carlitoplatanito / gulp-nunjucks-render

[Gulp](https://github.com/wearefractal/gulp) plugin to render [Nunjucks](http://mozilla.github.io/nunjucks/) templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle error?

spinxdigital opened this issue · comments

Here is my code.

gulp.task('nunjucks', function () {
  return gulp.src('html/pages/**/*.+(html|nunjucks)')
    .pipe($.nunjucksRender({
      path: ['html/templates']
    }))
    .pipe(gulp.dest('dist'));
});

@spinxdigital can you provide more details about the error you're seeing? There's not enough context in this comment.

Actually on each error on template compiling I was getting error and I had restart gulp watch.
But now I can handle error by below code (with plumber).

gulp.task('nunjucks', function () {

  return gulp.src('app/pages/**/*.+(html|nunjucks)')
    .pipe($.data(readTemplateData()))
    .pipe($.plumber({
      errorHandler: onError
    }))
    .pipe($.nunjucksRender({
      path: ['app/templates']
    }))
    .pipe(gulp.dest('dist'));
});