Created
March 20, 2016 19:45
-
-
Save mmikkel/1fa89933dc9dfa3f3037 to your computer and use it in GitHub Desktop.
Adding a custom filter to gulp-nunjucks-render
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var manageEnvironment = function(environment) { | |
environment.addFilter('custom', function(str) { | |
return 'Olav, du må vakne. Indianarane kjem.'; | |
}); | |
} | |
var htmlTask = function() { | |
return gulp.src(paths.src) | |
.pipe(data(getData)) | |
.on('error', handleErrors) | |
.pipe(render({ | |
path: [path.join(config.root.src, config.tasks.html.src)], | |
envOptions: { | |
watch: false | |
}, | |
manageEnv: manageEnvironment | |
})) | |
.on('error', handleErrors) | |
.pipe(gulpif(process.env.NODE_ENV == 'production', htmlmin(config.tasks.html.htmlmin))) | |
.pipe(gulp.dest(paths.dest)) | |
.pipe(browserSync.stream()) | |
} | |
gulp.task('html', htmlTask) | |
module.exports = htmlTask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment