mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
docs
This commit is contained in:
parent
2f7b78c03a
commit
42f3ad436d
18
docs/guide.1
18
docs/guide.1
|
|
@ -2003,18 +2003,22 @@ This is also useful for libraries that may not match extensions correctly\. For
|
|||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
For engines that do not comply with the Express specification, we can also wrap their api this way\.
|
||||
For engines that do not comply with the Express specification, we can also wrap their api this way\. Below we map \fI\.md\fR to render markdown files, rendering the html once since it will not change on subsequent calls, and support local substitution in the form of "{name}"\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
app\.register(\'\.foo\', {
|
||||
render: function(str, options) {
|
||||
// perhaps their api is
|
||||
// return foo\.toHTML(str, options);
|
||||
}
|
||||
});
|
||||
app\.register(\'\.md\', {
|
||||
compile: function(str, options){
|
||||
var html = md\.toHTML(str);
|
||||
return function(locals){
|
||||
return html\.replace(/\e{([^}]+)\e}/g, function(_, name){
|
||||
return locals[name];
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
.
|
||||
.fi
|
||||
.
|
||||
|
|
|
|||
|
|
@ -1504,14 +1504,21 @@ of layout.hamljs, we can register the engine as ".haml":</p>
|
|||
</code></pre>
|
||||
|
||||
<p>For engines that do not comply with the Express
|
||||
specification, we can also wrap their api this way.</p>
|
||||
specification, we can also wrap their api this way. Below
|
||||
we map <em>.md</em> to render markdown files, rendering the html once
|
||||
since it will not change on subsequent calls, and support local substitution
|
||||
in the form of "{name}".</p>
|
||||
|
||||
<pre><code> app.register('.foo', {
|
||||
render: function(str, options) {
|
||||
// perhaps their api is
|
||||
// return foo.toHTML(str, options);
|
||||
}
|
||||
});
|
||||
<pre><code> app.register('.md', {
|
||||
compile: function(str, options){
|
||||
var html = md.toHTML(str);
|
||||
return function(locals){
|
||||
return html.replace(/\{([^}]+)\}/g, function(_, name){
|
||||
return locals[name];
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
|
||||
<h3 id="app-listen-port-host-">app.listen([port[, host]])</h3>
|
||||
|
|
|
|||
|
|
@ -1126,14 +1126,21 @@ of layout.hamljs, we can register the engine as ".haml":
|
|||
app.register('.haml', require('haml-js'));
|
||||
|
||||
For engines that do not comply with the Express
|
||||
specification, we can also wrap their api this way.
|
||||
specification, we can also wrap their api this way. Below
|
||||
we map _.md_ to render markdown files, rendering the html once
|
||||
since it will not change on subsequent calls, and support local substitution
|
||||
in the form of "{name}".
|
||||
|
||||
app.register('.foo', {
|
||||
render: function(str, options) {
|
||||
// perhaps their api is
|
||||
// return foo.toHTML(str, options);
|
||||
}
|
||||
});
|
||||
app.register('.md', {
|
||||
compile: function(str, options){
|
||||
var html = md.toHTML(str);
|
||||
return function(locals){
|
||||
return html.replace(/\{([^}]+)\}/g, function(_, name){
|
||||
return locals[name];
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
### app.listen([port[, host]])
|
||||
|
||||
|
|
|
|||
|
|
@ -176,16 +176,6 @@ View.prototype.__defineGetter__('prefixPath', function(){
|
|||
*
|
||||
* app.register('.haml', require('haml-js'));
|
||||
*
|
||||
* For engines that do not comply with the Express
|
||||
* specification, we can also wrap their api this way.
|
||||
*
|
||||
* app.register('.foo', {
|
||||
* render: function(str, options) {
|
||||
* // perhaps their api is
|
||||
* // return foo.toHTML(str, options);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* @param {String} ext
|
||||
* @param {Object} obj
|
||||
* @api public
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user