sindresorhus / gulp-template

Render/precompile Lodash templates
MIT License
289 stars 77 forks source link

Can't get a custom template parser to work. #43

Closed motleydev closed 6 years ago

motleydev commented 6 years ago

I'm trying to pass an interpolate regex to the options, but can't seem to get it to work.

gulp.task('default', () =>
    gulp.src('templates/*.html')
        .pipe(data(() => ({
            test: 'random'
        })))
        .pipe(template({
            interpolate: /\[([\s\S]+?)\]/g
        }))
        .pipe(gulp.dest('dist'))
);

I want to find examples of [test] and replace it with my string.

motleydev commented 6 years ago

Found the issue, I think it's slightly unclear in the docs, but if you want to pass options to the template() function you need to pass null as the first parameter, which will, in turn, take the data passed into it, not actually null.