docs for res.render() and res.partial()
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 131970b · Browse files · 3 files·+24 added−4 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+24 added−4 removed
- other:+24 added−4 removed
Provenance
- Commit
07ce5d3- Tree
58b13bb- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
131970b
3 files changed+24 added−4 removed
modified:docs/migrate.1+1 added-1 removed
139 unmodified lines140 .IP "" 4141 .142 .nf143 144-res\.cookie(\'rememberme\', \'yes\', { expires: new Date(Date\.now() + 900000), httpOnly: true });144+res\.cookie(\'rememberme\', \'yes\', { expires: new Date(Date\.now() + 900000) });145 .146 .fi147 .148 .IP "" 081 unmodified linesmodified:docs/migrate.html+1 added-1 removed
279 unmodified lines280 <h3 id="res-cookie-">res.cookie()</h3>281 282 <p> Previously only directly values could be passed, so for example:</p>283 284-<pre><code>res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });284+<pre><code>res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000) });285 </code></pre>286 287 <p>However now we have the alternative <em>maxAge</em> property which may be used to set <em>expires</em> relative to <em>Date.now()</em> in milliseconds, so our example above can now become:</p>288 49 unmodified linesmodified:docs/migrate.md+22 added-2 removed
77 unmodified lines7879808182828384858613 unmodified lines10010110210310410410510610710810911011111211311411511611711811912012112212312412512612712812914 unmodified lines77 unmodified lines### res.cookie()
Previously only directly values could be passed, so for example:
res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true }); res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000) });
However now we have the alternative _maxAge_ property which may be used to set _expires_ relative to _Date.now()_ in milliseconds, so our example above can now become:
res.cookie('rememberme', 'yes', { maxAge: 900000 });13 unmodified lines });
The _stream threshold_ setting was removed.
### View Engine Compliance### res.render()
Previously locals were passed as a separate key: res.render('user', { layout: false, locals: { user: user }});
In Express 2.0 both the locals and the options are one in the same, meaning you cannot have a local variable named _layout_ as it is reserved for express, however this cleans up the API: res.render('user', { layout: false, user: user });
### res.partial()
Express 2.0 adds the _res.partial()_ method, helpful for rendering partial fragments over WebSockets or Ajax requests etc. The API is identical to the _partial()_ calls within views. // render a collection of comments res.partial('comment', [comment1, comment2]);
// render a single comment res.partial('comment', comment);
### Template Engine Compliance
To comply with Express previously engines needed the following signature: engine.render(str, options, function(err){});
14 unmodified lines