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
Provenance
- Commit
0b86ce2- Tree
a9faf90- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
548a070
3 files changed+93 added−0 removed
modified:docs/migrate.1+40 added
47 unmodified lines48 .fi49 .50 .IP "" 051 .52+.P53+Express 1\.x does \fInot\fR allow returning of a string\.54+.55 .SS "Running Applications"56 Previously a global function \fBrun()\fR, was available:57 .58 .IP "" 482 unmodified lines141 .142 .fi143 .144 .IP "" 0145+.146+.SS "View Rendering"147+View 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+.P150+Previously a view render looked something like this:151+.152+.IP "" 4153+.154+.nf155 156+get(\'/\', function(){157+ this\.render(\'index\.html\.haml\', {158+ locals: { title: \'My Site\' }159+ });160+});161+.162+.fi163+.164+.IP "" 0165+.166+.P167+We 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+.nf172+173+app\.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 lines188 res.send('hello world');189 });190 </code></pre>191 192+<p>Express 1.x does <em>not</em> allow returning of a string.</p>193+194 <h3 id="Running-Applications">Running Applications</h3>195 196 <p>Previously a global function <code>run()</code>, was available:</p>197 48 unmodified lines246 // ... respond247 });248 </code></pre>249 250+<h3 id="View-Rendering">View Rendering</h3>251+252+<p>View filenames no longer take the form <em>Express</em>.<em>TYPE</em>.<em>ENGINE</em>,253+the <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>,255+should now be <em>layout.haml</em>.</p>256+257+<p>Previously a view render looked something like this:</p>258+259+<pre><code>get('/', function(){260+ this.render('index.html.haml', {261+ locals: { title: 'My Site' }262+ });263+});264+</code></pre>265+266+<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 others267+remain the same.</p>268+269+<pre><code>app.get('/', function(req, res){270+ res.render('index.haml', {271+ locals: { title: 'My Site' }272+ });273+});274+</code></pre>275+276 </div>277 </div>278 </div>279 </body>1 unmodified linemodified:docs/migrate.md+25 added
33 unmodified lines34353637383940414241 unmodified lines8485868788899091929394959697989910010110210310410510610710810911011111233 unmodified lines app.get('/', function(req, res){ res.send('hello world'); });
Express 1.x does _not_ allow returning of a string.
### Running Applications
Previously a global function `run()`, was available:41 unmodified lines });
app.get('/user', function(){ // ... respond });
### View Rendering
View filenames no longer take the form _NAME_._TYPE_._ENGINE_,the _Content-Type_ can be set via `ServerResponse#contentType()` or`ServerResponse#header()`. For example what was previously _layout.html.haml_,should now be _layout.haml_.
Previously a view render looked something like this:
get('/', function(){ this.render('index.html.haml', { locals: { title: 'My Site' } }); });
We now have `ServerResponse#render()`, however the options passed to [haml](http://github.com/visionmedia/haml.js), [jade](http://github.com/visionmedia/jade), and othersremain the same.
app.get('/', function(req, res){ res.render('index.haml', { locals: { title: 'My Site' } }); });No newline at end of fileNo newline at end of file