Skip to content
Myr

Docs for "view engine" setting

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 98737f1 · Browse files · 3 files+92 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+92 added−0 removed

  • other:+92 added−0 removed

3 files+92 added−0 removed

modified:docs/guide.1+52 added
394 unmodified lines
395.fi396.397.IP "" 0398.399.P400The new \fIview engine\fR setting allows us to specify our default template engine, so for example when using Jade \fIhttp://github\.com/visionmedia/jade\fR we could set:401.402.IP "" 4403.404.nf405406app\.set(\'view engine\', \'jade\');407.408.fi409.410.IP "" 0411.412.P413Allowing us to render with:414.415.IP "" 4416.417.nf418419res\.render(\'index\');420.421.fi422.423.IP "" 0424.425.P426vs:427.428.IP "" 4429.430.nf431432res\.render(\'index\.jade\');433.434.fi435.436.IP "" 0437.438.P439When \fIview engine\fR is set, extensions are entirely optional, however we can still mix and match template engines:440.441.IP "" 4442.443.nf444445res\.render(\'another\-page\.ejs\');446.447.fi448.449.IP "" 0450.451.SS "View Partials"452The Express view system has built\-in support for partials and collections, which are sort of \"mini\" views representing a document fragment\. For example rather than iterating in a view to display comments, we would use a partial with collection support:453.454.IP "" 4
559 unmodified lines
modified:docs/guide.html+22 added
478 unmodified lines
479 });480});481</code></pre>482483<p>The new <em>view engine</em> setting allows us to specify our default template engine,484so for example when using <a href="http://github.com/visionmedia/jade">Jade</a> we could set:</p>485486<pre><code>app.set('view engine', 'jade');487</code></pre>488489<p>Allowing us to render with:</p>490491<pre><code>res.render('index');492</code></pre>493494<p>vs:</p>495496<pre><code>res.render('index.jade');497</code></pre>498499<p>When <em>view engine</em> is set, extensions are entirely optional, however we can still500mix and match template engines:</p>501502<pre><code>res.render('another-page.ejs');503</code></pre>504505<h3 id="View-Partials">View Partials</h3>506507<p>The Express view system has built-in support for partials and collections, which are508sort of "mini" views representing a document fragment. For example rather than iterating
370 unmodified lines
modified:docs/guide.md+18 added
243 unmodified lines
244 locals: { title: 'My Site' }245 });246 });247248The new _view engine_ setting allows us to specify our default template engine,249so for example when using [Jade](http://github.com/visionmedia/jade) we could set:250251 app.set('view engine', 'jade');252253Allowing us to render with:254255 res.render('index');256257vs:258259 res.render('index.jade');260261When _view engine_ is set, extensions are entirely optional, however we can still262mix and match template engines:263264 res.render('another-page.ejs');265266### View Partials267268The Express view system has built-in support for partials and collections, which are269sort of "mini" views representing a document fragment. For example rather than iterating
319 unmodified lines