There are two ways to set a default layout
- configuring the view engine's defaultLayout property (여기서는 이걸 사용)
- setting Express locals app.locals.layout.
언제든지 defaultlayout 없이 부를 수 있음. 아래 예처럼
app.get('/', (req, res, next) => {
res.render('home', {layout: false});
});
Handlebars ships with some built-in helpers, such as: with, if, each, etc. Most applications will need to extend this set of helpers to include app-specific logic and transformations. Beyond defining global helpers on Handlebars, this view engine supports ExpressHandlebars instance-level helpers via the helpers configuration property, and render-level helpers via options.helpers when calling the render() and renderView() methods.
The following example shows helpers being specified at each level:
app.js:
Creates a super simple Express app which shows the basic way to register ExpressHandlebars instance-level helpers, and override one at the render-level.