sindresorhus / gulp-nunjucks

Precompile Nunjucks templates
MIT License
152 stars 20 forks source link

Is it possible to pass the options when using a stream as data? #20

Open ganlanyuan opened 7 years ago

ganlanyuan commented 7 years ago

Like the example you gave:

const gulp = require('gulp');
const nunjucks = require('gulp-nunjucks');
const data = require('gulp-data');

gulp.task('default', () =>
    gulp.src('templates/greeting.html')
        .pipe(data(() => ({name: 'Sindre'})))
        .pipe(nunjucks.compile({
                  watch: true,
                  noCache: true
                }))
        .pipe(gulp.dest('dist'))
);

This one doesn't work. Is there any work around for this?

bi-kai commented 7 years ago

@ganlanyuan have a try to set the options as the second param in gulp-nunjucks, such as:

.pipe(nunjucks.compile({ type: "native" }, {
    tags: {
        blockStart: '<%',
        blockEnd: '%>',
        variableStart: '<$',
        variableEnd: '$>',
        commentStart: '<#',
        commentEnd: '#>'
    }
}))