Hi everybody I'm kind new in nodejs problems I hope o can found what I need as simple as possible So my base problem is how can I use multiple handlebars files in one handlebar page as sections Like to have a page for the headear and another for the body and others for footer and all that just by using nodejs and handlebars ... And thanks after all ^^
Asked
Active
Viewed 136 times
-2
-
Possible duplicate of [Node.js + Express + Handlebars.js + partial views](https://stackoverflow.com/questions/16385173/node-js-express-handlebars-js-partial-views) – Nikhil Unni Apr 09 '19 at 13:19
1 Answers
0
You can define the pages except main page as partials. Then you the files in your main file in the form of {{> filename}}
for eg:
views/
main.handelbars
partials/
-header.handelbars
-body.handelbars
-footer.handelbars
main.handlebars
<html>
<title>xxxxxx</title>
<head>
.....
</head>
{{> header}}
{{> body}}
{{> footer}}
</html>
header.handlebars
<header>
........
</header>
body.handlebars
<div>
........
</div>
footer.handlebars
<footer>
........
</footer>
Dont't forget to add the view engine and mention the public directory to views as well as the partials directory.

Nikhil Unni
- 739
- 5
- 12
-
Thanks to much for your answer I just would like to get more informations about je side ^^ – khalid mokhliss Apr 10 '19 at 17:17