Skip to content
Myr

Added view rendering migration section

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 548a070 · Browse files · 3 files+93 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+93 added−0 removed

  • other:+93 added−0 removed

3 files+93 added−0 removed

modified:docs/migrate.1+40 added
47 unmodified lines
48.fi49.50.IP "" 051.52.P53Express 1\.x does \fInot\fR allow returning of a string\.54.55.SS "Running Applications"56Previously a global function \fBrun()\fR, was available:57.58.IP "" 4
82 unmodified lines
141.142.fi143.144.IP "" 0145.146.SS "View Rendering"147View filenames no longer take the form \fINAME\fR\.\fITYPE\fR\.\fIENGINE\fR, the \fIContent\-Type\fR can be set via \fBServerResponse#contentType()\fR or \fBServerResponse#header()\fR\. For example what was previously \fIlayout\.html\.haml\fR, should now be \fIlayout\.haml\fR\.148.149.P150Previously a view render looked something like this:151.152.IP "" 4153.154.nf155156get(\'/\', function(){157 this\.render(\'index\.html\.haml\', {158 locals: { title: \'My Site\' }159 });160});161.162.fi163.164.IP "" 0165.166.P167We now have \fBServerResponse#render()\fR, however the options passed to haml \fIhttp://github\.com/visionmedia/haml\.js\fR, jade \fIhttp://github\.com/visionmedia/jade\fR, and others remain the same\.168.169.IP "" 4170.171.nf172173app\.get(\'/\', function(req, res){174 res\.render(\'index\.haml\', {175 locals: { title: \'My Site\' }176 });177});178.179.fi180.181.IP "" 0182
modified:docs/migrate.html+28 added
187 unmodified lines
188 res.send('hello world');189});190</code></pre>191192<p>Express 1.x does <em>not</em> allow returning of a string.</p>193194<h3 id="Running-Applications">Running Applications</h3>195196<p>Previously a global function <code>run()</code>, was available:</p>197
48 unmodified lines
246 // ... respond247});248</code></pre>249250<h3 id="View-Rendering">View Rendering</h3>251252<p>View filenames no longer take the form <em>Express</em>.<em>TYPE</em>.<em>ENGINE</em>,253the <em>Content-Type</em> can be set via <code>ServerResponse#contentType()</code> or254<code>ServerResponse#header()</code>. For example what was previously <em>layout.html.haml</em>,255should now be <em>layout.haml</em>.</p>256257<p>Previously a view render looked something like this:</p>258259<pre><code>get('/', function(){260 this.render('index.html.haml', {261 locals: { title: 'My Site' }262 });263});264</code></pre>265266<p>We now have <code>ServerResponse#render()</code>, however the options passed to <a href="http://github.com/visionmedia/haml.js">haml</a>, <a href="http://github.com/visionmedia/jade">jade</a>, and others267remain the same.</p>268269<pre><code>app.get('/', function(req, res){270 res.render('index.haml', {271 locals: { title: 'My Site' }272 });273});274</code></pre>275276</div>277 </div>278 </div>279 </body>
1 unmodified line
modified:docs/migrate.md+25 added