Pablo
Pablo

Reputation: 10602

res send 2 html files in Nodejs

I'm devloping a sample website in order the learn Node.js with express. In a routes file I have this code to render a page:

app.get('/new-product', requireLoggedIn, function(req,res){
    res.sendFile(path.join(__dirname+'/../views/new-product.html'));
    res.set('Access-Control-Allow-Origin', '*');
});

Is there a way I could have the page header (with the logo, menus, etc) in a separated html file so I can load the header in all pages from the same file, and the content of each page in another file?

Upvotes: 0

Views: 654

Answers (1)

Akram Saouri
Akram Saouri

Reputation: 1169

in order to load a piece of page in all pages , you need to use the EJS engine in place of html , just use <% include name_of_the_view %> in your ejs page and each time this page 'll be rendered , the name_of_the_view will be rendered with it learn more : http://www.embeddedjs.com/

Upvotes: 2

Related Questions