Removed "view options" setting. Closes #748
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent f36d079 · Browse files · 2 files·+4 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+4 added−14 removed
- other:+4 added−14 removed
Provenance
- Commit
914e4a4- Tree
170282e- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
f36d079
2 files changed+4 added−14 removed
modified:docs/guide.md+3 added-13 removed
105 unmodified lines106 107 * _home_ Application base path used for _res.redirect()_ and transparently handling mounted apps.108 * _views_ Root views directory defaulting to **CWD/views**109 * _view engine_ Default view engine name for views rendered without extensions110- * _view options_ An object specifying global view options110 * _view cache_ Enable view caching (enabled in production)111 * _charset_ Alter the default charset of "utf-8"112 * _case sensitive routes_ Enable case-sensitive routing113 * _strict routing_ When enabled trailing slashes are no longer ignored378 unmodified lines492 mix and match template engines:493 494 res.render('another-page.ejs');495 497-Express also provides the _view options_ setting, which is applied each time a view is rendered, so for example if you rarely use layouts you may set:496+ To apply application-level locals, or view engine options may be set using _app.local()_ or _app.locals()_, for example if we don't want layouts for most of our templates we may do:497 499- app.set('view options', {500- layout: false501- });498+ app.local('layout', false);499 503-Which can then be overridden within the _res.render()_ call if need be:500+Which can then be overridden within the _res.render()_ call if desired, and is otherwise functionally equivalent to passing directly to `res.render()`:501 502 res.render('myview.ejs', { layout: true });503 504 When an alternate layout is required, we may also specify a path. For example if we have _view engine_ set to _jade_ and a file named _./views/mylayout.jade_ we can simply pass:7 unmodified lines512 These paths may also be absolute:513 514 res.render('page', { layout: __dirname + '/../../mylayout.jade' });515 519-A good example of this is specifying custom _ejs_ opening and closing tags:520-521- app.set('view options', {522- open: '{{',523- close: '}}'524- });525-516 ### View Partials517 518 The Express view system has built-in support for partials and collections, which are "mini" views representing a document fragment. For example rather than iterating519 in a view to display comments, we could use partial collection:835 unmodified linesmodified:examples/layout-control/app.js+1 added-1 removed
8 unmodified lines910111213131415161715 unmodified lines8 unmodified lines
app.set('views', __dirname + '/views');
// set default layout, usually "layout"app.set('view options', { layout: 'layouts/default' });app.local('layout', 'layouts/default');
// Set our default template engine to "ejs"// which prevents the need for extensions// (although you can still mix and match)15 unmodified lines