Answer the question
In order to leave comments, you need to log in
How can I change the layout depending on the route?
How to change the layout depending on the routing, do I need to change the layout from the default to the layout of the admin panel?
const express = require('express'),
app = express(),
hbs = require('hbs');
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
hbs.registerPartials(path.join(__dirname, 'views/partials'));
app.use('/admin', require('./routes/admin'));
const express = require('express'),
app = express(),
AdminController = require('../controllers/AdminController'),
AdminRouter = express.Router();
AdminRouter.use(function (req, res, next) {
if(!req.session.user) {
return res.redirect('/auth/login');
}
app.set("view options", {layout: "admin/layout"});
next();
});
AdminRouter.get('/', AdminController.main);
Answer the question
In order to leave comments, you need to log in
he joked, he laughed.
req, res is already app so in the middle res.local.layout = 'str';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question