Answer the question
In order to leave comments, you need to log in
How to pass different data in gulp-ejs for different pages?
There is such a code, I want to transfer my data from json for each page.
But I don't understand how to separate them.
const data1 = require("./data.page1.json");
const data2 = require("./data.page2.json");
const data3 = require("./data.page3.json");
function ejsTemplate() {
return gulp.src(paths.ejs)
.pipe(ejs(data1)) <<<- тут
.pipe(rename({ extname: '.html' }))
.pipe(gulp.dest(paths.dist));
}
Answer the question
In order to leave comments, you need to log in
There is a similar question on stackoverflow
. Plus, there is a full gulp-ejs-template repository (link to Readme) that shows how to work directly with the package.
Also, look at code examples that solve this problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question