I have a file, let's say index.ejs
which I render using express this way:
res.render('index.ejs', {
projectName: req.params.name
}
Inside this ejs file, I include another file, let's say base.ejs
.
I'm trying to pass the variable projectName to base.ejs
.
I have tried the following approaches:
<%- include("path/to/base.ejs", {projectName: projectName})" %>
<%- include("path/to/base.ejs", {projectName: <%=projectName%>})" %>
<%- include("path/to/base.ejs", {projectName: '<%=projectName%>'})" %>
None of them seem to work. This is a similar answer I found how to include a template with parameters in EJS? but it doesn't seem to solve my problem.