Reputation: 508
So I'm learning the express framework for nodejs and am curious if I need a templating engine like ejs or pug to use the res.render('index.ejs')
function to serve html.
It seems like when I tried to serve up a basic html page without the template, it failed when I navigated to the page, res.render(index.html)
.
So I guess my question is, if I use res.render()
in express, do i have no choice but to use a templating engine?
Upvotes: 0
Views: 90
Reputation: 477
i had the same problem and they recommended me to try this
app.engine('html', require('ejs').renderFile);
it did not work for me, but maybe it will work for you.
Upvotes: 0
Reputation: 226
You need to use res.send file found here res.render is usually used to render a template via a template engine. So it is up to how you design the project - whether you send all your html code from server via a template engine - or use a client side app like angular .
Upvotes: 1