I'm trying to include partial in another partial using EJS engine like this:
--First Partials
-----Second Partial
I get an error:
Could not find the include file
Can anyone help me? This is my code: Part #1
<!DOCTYPE html>
<html lang="ru">
<%- include parts/header %>
<body>
<%- include parts/section %>
</body>
</html>
Part #2
<div class="de">
<img src="img/de.svg" class="development" alt="">
<%- include parts/postBlog %>
</div>
With Express 3.0:
<%- include myview.ejs %>
the path is relative from the caller who includes the file, not from the views directory set with :
app.set("views", "path/to/views");
If you are in the same direction, use that
<% include ./parts/header%>
<% include ./parts/section%>
If you want to back, use double dots.
<% include ../parts/header%>
<% include ../parts/section%>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.