In my express app other ejs file working perfectly but when i tried to import an ejs templates it's not working even tho it's syntax is correct

Viewed 17

here I tried to include a template that is in the layout folder. I wanted to include another file named "index.ejs" in the same directory. i thought this syntax is correct but it is not working in here, what is the problem??

<%- include("layout /header")%>
    <main>
        <p>This is Register page</p>
    </main>
    <%- include("layout /footer")%>```




</pre>[![enter image description here][1]][1]

[![this is the template i wanted to include][2]][2]
**this is my error message**

Error: F:\passportJs\authentication-by-passportjs\views\index.ejs:1
 >> 1| <%- include("layout /header")%>

    2|     <main>

    3|         <p>This is home page</p>

    4|     </main>


Could not find the include file "layout /header"
    at getIncludePath (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:185:13)
    at includeFile (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:311:19)
    at include (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:701:16)
    at eval ("F:\\passportJs\\authentication-by-passportjs\\views\\index.ejs":10:17)
    at index (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:703:17)
    at tryHandleCache (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:274:36)
    at View.exports.renderFile [as engine] (F:\passportJs\authentication-by-passportjs\node_modules\ejs\lib\ejs.js:491:10)
    at View.render (F:\passportJs\authentication-by-passportjs\node_modules\express\lib\view.js:135:8)
    at tryRender (F:\passportJs\authentication-by-passportjs\node_modules\express\lib\application.js:657:10)
    at Function.render (F:\passportJs\authentication-by-passportjs\node_modules\express\lib\application.js:609:3)


  [1]: https://i.stack.imgur.com/5Pj8V.png
  [2]: https://i.stack.imgur.com/MBsUC.png
0 Answers
Related