Reputation: 620
I'm migrating from grunt to gulp and looking to use gulp-processhtml (currently using grunt-processhtml). I pass in the parameters the same way I do in grunt, but the variables passed are not found.
The Gulp code:
var environment = 'dev';
var processHTMLOptions = {
options: {
process: true,
data: {
message: 'Processed HTML',
env: `environment: "${environment}",`
}
}
};
gulp.task('html:dist', () => {
return gulp.src('./src')
.pipe(processHTML(processHTMLOptions))
.pipe(gulp.dest('./build'));
});
and the HTML:
<!-- build:template
<%= message %>
<%= env %>
/build -->
The error I get:
((__t = ( message )) == null ? '' : __t);
^
ReferenceError: message is not defined
Upvotes: 0
Views: 296
Reputation: 620
I was able to figure out the issue. Unlike grunt-processhtml, gulp-processhtml only expects the options data to be passed without any other elements ('options'). Here is an example of how to pass variable to gulp-processhtml:
var processHTMLOptions = {
process: true,
data: {
message: 'Processed HTML',
version: `code_version: "${pkg.version}",`,
env: `environment: "${environment}",`
}
};
Upvotes: 1