Well this is my file structure.
modules
------------users
---------------------views
-----------------------------file.handlebars
public
routes
views
app.js
and other folders and files
but my problem is that i have two views folders
and i am able to set viewengine only to one folder
// View Engine
app.set("views", path.join(__dirname, "views"));
app.engine(
"handlebars",
exphbs({
defaultLayout: "layout"
})
);
app.set("view engine", "handlebars");
is there any way how can i set viewengine to two folders and change in route as i need?
Something like this.
router.get("/register", function (req, res) {
res.render("OPTION1/register" , {title: 'Register'});
}
});
router.get("/hfghf", function (req, res) {
res.render("OPTION2/hfghgf" , {title: 'hfghgfh'});
}
});
Pass the multiples views directory as array into it. Working in express 4.x
app.set("views", [path.join(__dirname, "views"),path.join(__dirname,'other_views')]);