How to use ejs "include" in templates
See original GitHub issueHello,
I am trying to use this project with ejs. I have a lot of pain to understand how the rendering system works and how the template files coulds / should be structured and chained.
In my case, I can’t maket it work without having one folder by template, containing a html.ejs file. Is it normal and mandatory or can we specify a filePath ?
Here is my app structure :
app.js
templates
- emails
- administrators
- bottom-wrapper
- html.ejs
- notification-note
- html.ejs
- top-wrapper
- html.ejs
I want to render the notification-note template, which contains :
<%- include('../top-wrapper') %>
TEST
<%- include('../bottom-wrapper') %>
Here is the way I’m calling it :
const email = new Email({
message: message,
transport: EmailService.transport(),
views: {
options: {
extension: 'ejs'
},
root: path.join('templates', 'emails')
}
});
return email.send({
template: "administrators/notification-note",
locals: locals
})
I run into this error :
Could not find the include file "../top-wrapper"
I can’t figure out how to make this work. Did someone already do this ?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
How To Use EJS to Template Your Node Application
Use <% - include( 'RELATIVE/PATH/TO/FILE' ) %> to embed an EJS partial in another file. The hyphen <%- instead of just <% to...
Read more >EJS -- Embedded JavaScript templates
Includes are relative to the template with the include call. (This requires the 'filename' option.) For example if you have "./views/users.ejs" and "./views/ ......
Read more >In EJS template engine, how do I "include" a footer?
include is a function Includes are relative to the template with the include call. (This requires the 'filename' option.) For example if you ......
Read more >How to use EJS to template your Node.js application
Template your Node.js apps with EJS, a simple and powerful templating ... Create a new folder where you want to put the project...
Read more >Using EJS Template Engine With Express.js
js file, open your editor, and write down the following code: 1 2 3 4 5 6 7 8 9 10 11 12...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
<%- include(‘file path’); -%>
It worked for me when I added the ‘-’ at the end
Hi, i have the same situation and here’s how i solve it
and on the html.ejs of new-question