Skip to content
Myr

Docs for "view options"

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 5311bd3 · Browse files · 3 files+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+20 added−0 removed

  • other:+20 added−0 removed

3 files+20 added−0 removed

modified:docs/guide.md+18 added
81 unmodified lines
82 * _env_ Application environment set internally, use _app.set('env')_ on _Server#listen()_83 * _home_ Application base path used for _res.redirect()_ and transparently handling mounted apps.84 * _views_ Root views directory defaulting to **CWD/views**85 * _view engine_ Default view engine name for views rendered without extensions86 * _view options_ An object specifying global view options87 * _partials_ Root view partials directory defaulting to _views_/partials. 8889### Routing90
190 unmodified lines
281mix and match template engines:282283 res.render('another-page.ejs');284285Express 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:286287 app.set('view options', {288 layout: false289 });290291Which can then be overridden within the `res.render()` call if need be:292293 res.render('myview.ejs', { layout: true });294295A good example of this is specifying custom _ejs_ opening and closing tags:296297 app.set('view options', {298 open: '{{',299 close: '}}'300 });301302### View Partials303304The Express view system has built-in support for partials and collections, which are305sort of "mini" views representing a document fragment. For example rather than iterating
371 unmodified lines
modified:docs/index.md+1 added
modified:Readme.md+1 added