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
Provenance
- Commit
1810c9b- Tree
30f4572- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
98737f1
3 files changed+92 added−0 removed
modified:docs/guide.1+52 added
394 unmodified lines395 .fi396 .397 .IP "" 0398 .399+.P400+The 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+.nf405+406+app\.set(\'view engine\', \'jade\');407+.408+.fi409+.410+.IP "" 0411+.412+.P413+Allowing us to render with:414+.415+.IP "" 4416+.417+.nf418+419+res\.render(\'index\');420+.421+.fi422+.423+.IP "" 0424+.425+.P426+vs:427+.428+.IP "" 4429+.430+.nf431+432+res\.render(\'index\.jade\');433+.434+.fi435+.436+.IP "" 0437+.438+.P439+When \fIview engine\fR is set, extensions are entirely optional, however we can still mix and match template engines:440+.441+.IP "" 4442+.443+.nf444+445+res\.render(\'another\-page\.ejs\');446+.447+.fi448+.449+.IP "" 0450+.451 .SS "View Partials"452 The 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 "" 4559 unmodified linesmodified:docs/guide.html+22 added
478 unmodified lines479 });480 });481 </code></pre>482 483+<p>The new <em>view engine</em> setting allows us to specify our default template engine,484+so for example when using <a href="http://github.com/visionmedia/jade">Jade</a> we could set:</p>485+486+<pre><code>app.set('view engine', 'jade');487+</code></pre>488+489+<p>Allowing us to render with:</p>490+491+<pre><code>res.render('index');492+</code></pre>493+494+<p>vs:</p>495+496+<pre><code>res.render('index.jade');497+</code></pre>498+499+<p>When <em>view engine</em> is set, extensions are entirely optional, however we can still500+mix and match template engines:</p>501+502+<pre><code>res.render('another-page.ejs');503+</code></pre>504+505 <h3 id="View-Partials">View Partials</h3>506 507 <p>The Express view system has built-in support for partials and collections, which are508 sort of "mini" views representing a document fragment. For example rather than iterating370 unmodified linesmodified:docs/guide.md+18 added
243 unmodified lines244 locals: { title: 'My Site' }245 });246 });247 248+The new _view engine_ setting allows us to specify our default template engine,249+so for example when using [Jade](http://github.com/visionmedia/jade) we could set:250+251+ app.set('view engine', 'jade');252+253+Allowing us to render with:254+255+ res.render('index');256+257+vs:258+259+ res.render('index.jade');260+261+When _view engine_ is set, extensions are entirely optional, however we can still262+mix and match template engines:263+264+ res.render('another-page.ejs');265+266 ### View Partials267 268 The Express view system has built-in support for partials and collections, which are269 sort of "mini" views representing a document fragment. For example rather than iterating319 unmodified lines