Skip to content
Myr

Fixed reload views example

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 492f70f · Browse files · 4 files+210 added−210 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+210 added−210 removed

  • other:+210 added−210 removed

4 files+210 added−210 removed

modified:docs/api.html+207 added-207 removed
149 unmodified lines
150<span class="variable">require</span>(<span class="string">'./request'</span>);151<span class="variable">require</span>(<span class="string">'./response'</span>);152</code></pre>153</td>154</tr><tr class="filename"><td><h2 id="lib/express/request.js"><a href="#">request</a></h2></td><td>lib/express/request.js</td></tr><tr class="code">155<td class="docs">156<p>Module dependencies.157 </p>158</td>159<td class="code">160<pre><code><span class="keyword">var</span> <span class="variable">http</span> = <span class="variable">require</span>(<span class="string">'http'</span>),161 <span class="variable">utils</span> = <span class="variable">require</span>(<span class="string">'./utils'</span>),162 <span class="variable">mime</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>).<span class="variable">mime</span>;</code></pre>163</td>164</tr>165<tr class="code">166<td class="docs">167<p>Return request header or optional default.</p>168169<h2>Examples</h2>170171<pre><code>req.header('Content-Type');172// =&gt; "text/plain"173174req.header('content-type');175// =&gt; "text/plain"176177req.header('Accept');178// =&gt; undefined179180req.header('Accept', 'text/html');181// =&gt; "text/html"</code></pre>182183<h2></h2>184185<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>param</strong>: <em>String</em> defaultValue</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>186</td>187<td class="code">188<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">header</span> = <span class="keyword">function</span>(<span class="variable">name</span>, <span class="variable">defaultValue</span>){189 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>.<span class="variable">toLowerCase</span>()] || <span class="variable">defaultValue</span>;190};</code></pre>191</td>192</tr>193<tr class="code">194<td class="docs">195<p>Check if the <em>Accept</em> header is present, and includes the given <code>type</code>.</p>196197<p>When the <em>Accept</em> header is not present <code>true</code> is returned. Otherwise198the given <code>type</code> is matched by an exact match, and then subtypes. You199may pass the subtype such as "html" which is then converted internally200to "text/html" using the mime lookup table.</p>201202<h2>Examples</h2>203204<pre><code>// Accept: text/html205req.accepts('html');206// =&gt; true207208// Accept: text/*; application/json209req.accepts('html');210req.accepts('text/html');211req.accepts('text/plain');212req.accepts('application/json');213// =&gt; true214215req.accepts('image/png');216req.accepts('png');217// =&gt; false</code></pre>218219<h2></h2>220221<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>return</strong>: <em>Boolean</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>222</td>223<td class="code">224<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">accepts</span> = <span class="keyword">function</span>(<span class="variable">type</span>){225 <span class="keyword">var</span> <span class="variable">accept</span> = <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Accept'</span>);226 <span class="keyword">if</span> (!<span class="variable">accept</span> || <span class="variable">accept</span> === '*</code></pre>227</td>228</tr>229<tr class="code">230<td class="docs">231<p>') {232 return true;233 } else if (type) {234 // Allow "html" vs "text/html" etc235 if (type.indexOf('/') &lt; 0) {236 type = mime.types['.' + type];237 }238 // Check if we have a direct match239 if (accept.indexOf(type) &gt;= 0) {240 return true;241 // Check if we have type/<em>242 } else {243 type = type.split('/')[0] + '/</em>';244 return accept.indexOf(type) &gt;= 0;245 }246 } else {247 return false;248 }249};</p>250251<p>/**252Return the value of param <code>name</code> when present.</p>253254<ul><li>Checks route placeholders, ex: <em>/user/:id</em></li><li>Checks query string params, ex: ?id=12</li><li>Checks urlencoded body params, ex: id=12</li></ul>255256<p>To utilize urlencoded request bodies, <code>req.body</code>257should be an object. This can be done by using258the <code>connect.bodyDecoder</code> middleware.</p>259260<h2></h2>261262<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>263</td>264<td class="code">265<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">param</span> = <span class="keyword">function</span>(<span class="variable">name</span>){266 <span class="comment">// Route params like /user/:id</span>267 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {268 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>]; 269 }270 <span class="comment">// Query string params</span>271 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {272 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>]; 273 }274 <span class="comment">// Request body params via connect.bodyDecoder</span>275 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">body</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {276 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>];277 }278};</code></pre>279</td>280</tr>281<tr class="code">282<td class="docs">283<p>Queue flash <code>msg</code> of the given <code>type</code>.</p>284285<h2>Examples</h2>286287<pre><code> req.flash('info', 'email sent');288 req.flash('error', 'email delivery failed');289 req.flash('info', 'email re-sent');290 // =&gt; 2291292 req.flash('info');293 // =&gt; ['email sent', 'email re-sent']294295 req.flash('info');296 // =&gt; []297298 req.flash();299 // =&gt; { error: ['email delivery failed'], info: [] }</code></pre>300301<h2></h2>302303<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>param</strong>: <em>String</em> msg</p></li><li><p><strong>return</strong>: <em>Array | Object | Number</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>304</td>305<td class="code">306<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">flash</span> = <span class="keyword">function</span>(<span class="variable">type</span>, <span class="variable">msg</span>){307 <span class="keyword">var</span> <span class="variable">msgs</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> || {};308 <span class="keyword">if</span> (<span class="variable">type</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">msg</span>) {309 <span class="variable">msg</span> = <span class="variable">utils</span>.<span class="variable">miniMarkdown</span>(<span class="variable">utils</span>.<span class="variable">htmlEscape</span>(<span class="variable">msg</span>));310 <span class="keyword">return</span> (<span class="variable">msgs</span>[<span class="variable">type</span>] = <span class="variable">msgs</span>[<span class="variable">type</span>] || []).<span class="variable">push</span>(<span class="variable">msg</span>);311 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">type</span>) {312 <span class="keyword">var</span> <span class="variable">arr</span> = <span class="variable">msgs</span>[<span class="variable">type</span>];313 <span class="keyword">delete</span> <span class="variable">msgs</span>[<span class="variable">type</span>];314 <span class="keyword">return</span> <span class="variable">arr</span> || [];315 } <span class="keyword">else</span> {316 <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> = {};317 <span class="keyword">return</span> <span class="variable">msgs</span>;318 }319};320321<span class="comment">// Callback for isXMLHttpRequest / xhr</span>322323<span class="keyword">function</span> <span class="variable">isxhr</span>() {324 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'X-Requested-With'</span>, <span class="string">''</span>).<span class="variable">toLowerCase</span>() === <span class="string">'xmlhttprequest'</span>;325}</code></pre>326</td>327</tr>328<tr class="code">329<td class="docs">330<p>Check if the request was an <em>XMLHttpRequest</em>.</p>331332<h2></h2>333334<ul><li><p><strong>return</strong>: <em>Boolean</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>335</td>336<td class="code">337<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'isXMLHttpRequest'</span>, <span class="variable">isxhr</span>);338<span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'xhr'</span>, <span class="variable">isxhr</span>);</code></pre>339</td>340</tr><tr class="filename"><td><h2 id="lib/express/response.js"><a href="#">response</a></h2></td><td>lib/express/response.js</td></tr><tr class="code">341<td class="docs">342<p>Module dependencies.343 </p>
448 unmodified lines
792 <span class="keyword">return</span> <span class="variable">arguments</span>.<span class="variable">callee</span>;793})(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);794</code></pre>795</td>610</tr><tr class="filename"><td><h2 id="lib/express/request.js"><a href="#">request</a></h2></td><td>lib/express/request.js</td></tr><tr class="code">796</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">797<td class="docs">612<p>Module dependencies.613 </p>614</td>615<td class="code">616<pre><code><span class="keyword">var</span> <span class="variable">http</span> = <span class="variable">require</span>(<span class="string">'http'</span>),617 <span class="variable">utils</span> = <span class="variable">require</span>(<span class="string">'./utils'</span>),618 <span class="variable">mime</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>).<span class="variable">mime</span>;</code></pre>619</td>620</tr>621<tr class="code">622<td class="docs">623<p>Return request header or optional default.</p>798<p>Parse mini markdown implementation.799The following conversions are supported,800primarily for the "flash" middleware:</p>801625<h2>Examples</h2>802<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;803 <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;804 <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>805627<pre><code>req.header('Content-Type');628// =&gt; "text/plain"629630req.header('content-type');631// =&gt; "text/plain"632633req.header('Accept');634// =&gt; undefined635636req.header('Accept', 'text/html');637// =&gt; "text/html"</code></pre>638806<h2></h2>807641<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>param</strong>: <em>String</em> defaultValue</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>808<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>809</td>810<td class="code">644<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">header</span> = <span class="keyword">function</span>(<span class="variable">name</span>, <span class="variable">defaultValue</span>){645 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>.<span class="variable">toLowerCase</span>()] || <span class="variable">defaultValue</span>;811<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){812 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)813 .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)814 .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)815 .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);816};</code></pre>817</td>818</tr>819<tr class="code">820<td class="docs">651<p>Check if the <em>Accept</em> header is present, and includes the given <code>type</code>.</p>821<p>Escape special characters in the given string of html.</p>822653<p>When the <em>Accept</em> header is not present <code>true</code> is returned. Otherwise654the given <code>type</code> is matched by an exact match, and then subtypes. You655may pass the subtype such as "html" which is then converted internally656to "text/html" using the mime lookup table.</p>657658<h2>Examples</h2>659660<pre><code>// Accept: text/html661req.accepts('html');662// =&gt; true663664// Accept: text/*; application/json665req.accepts('html');666req.accepts('text/html');667req.accepts('text/plain');668req.accepts('application/json');669// =&gt; true670671req.accepts('image/png');672req.accepts('png');673// =&gt; false</code></pre>674823<h2></h2>824677<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>return</strong>: <em>Boolean</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>825<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>826</td>827<td class="code">680<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">accepts</span> = <span class="keyword">function</span>(<span class="variable">type</span>){681 <span class="keyword">var</span> <span class="variable">accept</span> = <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Accept'</span>);682 <span class="keyword">if</span> (!<span class="variable">accept</span> || <span class="variable">accept</span> === '*</code></pre>683</td>684</tr>685<tr class="code">686<td class="docs">687<p>') {688 return true;689 } else if (type) {690 // Allow "html" vs "text/html" etc691 if (type.indexOf('/') &lt; 0) {692 type = mime.types['.' + type];693 }694 // Check if we have a direct match695 if (accept.indexOf(type) &gt;= 0) {696 return true;697 // Check if we have type/<em>698 } else {699 type = type.split('/')[0] + '/</em>';700 return accept.indexOf(type) &gt;= 0;701 }702 } else {703 return false;704 }705};</p>706707<p>/**708Return the value of param <code>name</code> when present.</p>709710<ul><li>Checks route placeholders, ex: <em>/user/:id</em></li><li>Checks query string params, ex: ?id=12</li><li>Checks urlencoded body params, ex: id=12</li></ul>711712<p>To utilize urlencoded request bodies, <code>req.body</code>713should be an object. This can be done by using714the <code>connect.bodyDecoder</code> middleware.</p>715716<h2></h2>717718<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>719</td>720<td class="code">721<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">param</span> = <span class="keyword">function</span>(<span class="variable">name</span>){722 <span class="comment">// Route params like /user/:id</span>723 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {724 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>]; 725 }726 <span class="comment">// Query string params</span>727 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {728 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>]; 729 }730 <span class="comment">// Request body params via connect.bodyDecoder</span>731 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">body</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {732 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>];733 }828<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {829 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)830 .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)831 .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)832 .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)833 .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);834};</code></pre>835</td>736</tr>737<tr class="code">738<td class="docs">739<p>Queue flash <code>msg</code> of the given <code>type</code>.</p>740741<h2>Examples</h2>742743<pre><code> req.flash('info', 'email sent');744 req.flash('error', 'email delivery failed');745 req.flash('info', 'email re-sent');746 // =&gt; 2747748 req.flash('info');749 // =&gt; ['email sent', 'email re-sent']750751 req.flash('info');752 // =&gt; []753754 req.flash();755 // =&gt; { error: ['email delivery failed'], info: [] }</code></pre>756757<h2></h2>758759<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>param</strong>: <em>String</em> msg</p></li><li><p><strong>return</strong>: <em>Array | Object | Number</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>760</td>761<td class="code">762<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">flash</span> = <span class="keyword">function</span>(<span class="variable">type</span>, <span class="variable">msg</span>){763 <span class="keyword">var</span> <span class="variable">msgs</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> || {};764 <span class="keyword">if</span> (<span class="variable">type</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">msg</span>) {765 <span class="variable">msg</span> = <span class="variable">utils</span>.<span class="variable">miniMarkdown</span>(<span class="variable">utils</span>.<span class="variable">htmlEscape</span>(<span class="variable">msg</span>));766 <span class="keyword">return</span> (<span class="variable">msgs</span>[<span class="variable">type</span>] = <span class="variable">msgs</span>[<span class="variable">type</span>] || []).<span class="variable">push</span>(<span class="variable">msg</span>);767 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">type</span>) {768 <span class="keyword">var</span> <span class="variable">arr</span> = <span class="variable">msgs</span>[<span class="variable">type</span>];769 <span class="keyword">delete</span> <span class="variable">msgs</span>[<span class="variable">type</span>];770 <span class="keyword">return</span> <span class="variable">arr</span> || [];771 } <span class="keyword">else</span> {772 <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> = {};773 <span class="keyword">return</span> <span class="variable">msgs</span>;774 }775};776777<span class="comment">// Callback for isXMLHttpRequest / xhr</span>778779<span class="keyword">function</span> <span class="variable">isxhr</span>() {780 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'X-Requested-With'</span>, <span class="string">''</span>).<span class="variable">toLowerCase</span>() === <span class="string">'xmlhttprequest'</span>;781}</code></pre>782</td>783</tr>784<tr class="code">785<td class="docs">786<p>Check if the request was an <em>XMLHttpRequest</em>.</p>787788<h2></h2>789790<ul><li><p><strong>return</strong>: <em>Boolean</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>791</td>792<td class="code">793<pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'isXMLHttpRequest'</span>, <span class="variable">isxhr</span>);794<span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'xhr'</span>, <span class="variable">isxhr</span>);</code></pre>795</td>836</tr><tr class="filename"><td><h2 id="lib/express/view.js"><a href="#">view</a></h2></td><td>lib/express/view.js</td></tr><tr class="code">837<td class="docs">838<p>Module dependencies.839 </p>
210 unmodified lines
1050 }1051};1052</code></pre>1053</td>1014</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">1015<td class="docs">1016<p>Parse mini markdown implementation.1017The following conversions are supported,1018primarily for the "flash" middleware:</p>10191020<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;1021 <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;1022 <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>10231024<h2></h2>10251026<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>1027</td>1028<td class="code">1029<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){1030 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)1031 .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)1032 .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)1033 .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);1034};</code></pre>1035</td>1036</tr>1037<tr class="code">1038<td class="docs">1039<p>Escape special characters in the given string of html.</p>10401041<h2></h2>10421043<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>1044</td>1045<td class="code">1046<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {1047 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)1048 .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)1049 .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)1050 .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)1051 .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);1052};</code></pre>1053</td>1054</tr> </body>1055</html></tbody></table>
modified:docs/guide.1+1 added-1 removed
122 unmodified lines
123.IP "\(bu" 4124\fIview engine\fR Default view engine name for views rendered without extensions125.126.IP "\(bu" 4127\fIreload views\fR Reloads altered views, by default watches for \fImtime\fR changes with with a 5 minute interval\. Example: \fBapp\.set(\'reload views\', { interval: 60000 });\fR127\fIreload views\fR Reloads altered views, by default watches for \fImtime\fR changes with with a 5 minute interval\. Example: \fIapp\.set(\'reload views\', 60000);\fR128.129.IP "" 0130.131.SS "Routing"
403 unmodified lines
modified:docs/guide.html+1 added-1 removed
276 unmodified lines
277<li><em>home</em> Application base path used with <em>res.redirect()</em></li>278<li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>279<li><em>view engine</em> Default view engine name for views rendered without extensions</li>280<li><em>reload views</em> Reloads altered views, by default watches for <em>mtime</em> changes with281 with a 5 minute interval. Example: <code>app.set('reload views', { interval: 60000 });</code></li>281 with a 5 minute interval. Example: <em>app.set('reload views', 60000);</em></li>282</ul>283284285<h3 id="Routing">Routing</h3>
282 unmodified lines
modified:docs/guide.md+1 added-1 removed
70 unmodified lines
71 * _home_ Application base path used with _res.redirect()_72 * _views_ Root views directory defaulting to **CWD/views**73 * _view engine_ Default view engine name for views rendered without extensions74 * _reload views_ Reloads altered views, by default watches for _mtime_ changes with75 with a 5 minute interval. Example: `app.set('reload views', { interval: 60000 });`75 with a 5 minute interval. Example: _app.set('reload views', 60000);_7677### Routing7879Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.
250 unmodified lines