gulp-html-replace
gulp-html-replace copied to clipboard
Conditional Replacement
I use gulp-html-replace in a small static page. It consists of 7 different pages with a bootstrap navigation. I want to set the CSS class "active" for different HTML pages in the appropriate navigation and load the entire navigation from a template like I did with the footer.
gulp.task('buildHTML', function() {
gulp.src('src/html/*.html')
.pipe(htmlreplace({
footer: gulp.src('src/html/parts/footer.part.html'),
js: {
src: ['jquery-3.2.1.min.js', 'bootstrap.min.js'],
tpl: '<script type="text/javascript" src="/js/%s"></script>'
}
}))
.pipe(gulp.dest(rootDir + '/'));
});
Is this possible?