Skip to content

Commit eac8710

Browse files
authored
Merge pull request #249 from jfbrennan/master
Provide default for defaultLayout
2 parents 6ce977a + 87f7c11 commit eac8710

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var exphbs = require('express-handlebars');
9595

9696
var app = express();
9797

98-
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
98+
app.engine('handlebars', exphbs());
9999
app.set('view engine', 'handlebars');
100100

101101
app.get('/', function (req, res) {
@@ -356,7 +356,7 @@ The string path to the directory where the partials templates reside or object w
356356
**Note:** Multiple partials dirs can be used by making `partialsDir` an array of strings, and/or config objects as described above. The namespacing feature is useful if multiple partials dirs are used and their file paths might clash.
357357

358358
#### `defaultLayout`
359-
The string name or path of a template in the `layoutsDir` to use as the default layout. This is overridden by a `layout` specified in the app or response `locals`. **Note:** A falsy value will render without a layout; e.g., `res.render('home', {layout: false});`.
359+
The string name or path of a template in the `layoutsDir` to use as the default layout. `main` is used as the default. This is overridden by a `layout` specified in the app or response `locals`. **Note:** A falsy value will render without a layout; e.g., `res.render('home', {layout: false});`.
360360

361361
#### `helpers`
362362
An object which holds the helper functions used when rendering templates with this `ExpressHandlebars` instance. When rendering a template, a collection of helpers will be generated by merging: `handlebars.helpers` (global), `helpers` (instance), and `options.helpers` (render-level). This allows Handlebars' `registerHelper()` function to operate as expected, will providing two extra levels over helper overrides.

examples/advanced/server.js

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var app = express();
1010

1111
// Create `ExpressHandlebars` instance with a default layout.
1212
var hbs = exphbs.create({
13-
defaultLayout: 'main',
1413
helpers : helpers,
1514

1615
// Uses multiple partials dirs, templates in "shared/templates/" are shared

examples/basic/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var express = require('express'),
55

66
var app = express();
77

8-
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
8+
app.engine('handlebars', exphbs());
99
app.set('view engine', 'handlebars');
1010

1111
app.get('/', function (req, res) {

lib/express-handlebars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function ExpressHandlebars(config) {
2626
extname : '.handlebars',
2727
layoutsDir : undefined, // Default layouts directory is relative to `express settings.view` + `layouts/`
2828
partialsDir : undefined, // Default partials directory is relative to `express settings.view` + `partials/`
29-
defaultLayout : undefined,
29+
defaultLayout : 'main',
3030
helpers : undefined,
3131
compilerOptions: undefined,
3232
}, config);

0 commit comments

Comments
 (0)