Answer the question
In order to leave comments, you need to log in
Include HTML with conditions?
Given: there is a footer, it has a block that is different on different pages, block A, block B, block C.
The footer is a separate file that is connected using include.
<include src="source/html-blocks/block_footer.html"></include>
gulp.task("html", function () {
return gulp.src("source/*.html")
.pipe(posthtml([
include()
]))
.pipe(gulp.dest("build"));
});
Answer the question
In order to leave comments, you need to log in
Use full-fledged template engines, not any surrogates.
For example twig (gulp-twig for layout)
{% if some_variable == 2 %}
{% include "file1.twig" %}
{% else %}
{% include "file2.twig" %}
{% endif %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question