app.engine() docs
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 c937c79 · Browse files · 3 files·+45 added−12 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+45 added−12 removed
- other:+45 added−12 removed
Provenance
- Commit
fab3e91- Tree
a98a01c- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent
c937c79
3 files changed+45 added−12 removed
modified:docs/application.md+15 added-4 removed
9 unmodified lines10111213141516141516171819202122232425262728292130313233343536145 unmodified linesExpand all9 unmodified lines
# app.engine()
Register the given template engine callback `fn` as `ext`. For example if you wanted to map the EJS template engine to ".html" files, rather than ".ejs" files, you could do the following. as `ext`. By default will `require()` the engine based on the file extension. For example if you try to render a "foo.jade" file Express will invoke the following internally: app.engine('jade', require('jade').__express); For engines that do not provide `.__express` out of the box, or if you wish to "map" a different extension to the template engine you may use this method. For example mapping the EJS template engine to ".html" files app.engine('html', require('ejs').renderFile); In this case EJS provides a `.renderFile()` method with the same signature that Express expects: `(path, options, callback)`. the same signature that Express expects: `(path, options, callback)`, though note that it aliases this method as `ejs.__express` internally so if you're using ".ejs" extensions you dont need to do anything. Some template engines do not follow this convention, the [Consolidate.js](https://github.com/visionmedia/consolidate.js) library was created to map all of node's popular template145 unmodified linesExpand allmodified:docs/express.md+15 added-4 removed
9 unmodified lines10 11 # app.engine()12 13 Register the given template engine callback `fn`14- as `ext`. For example if you wanted to map the EJS15- template engine to ".html" files, rather than ".ejs" files,16- you could do the following.14+ as `ext`.15 16+ By default will `require()` the engine based on the17+ file extension. For example if you try to render18+ a "foo.jade" file Express will invoke the following internally:19+ 20+ app.engine('jade', require('jade').__express);21+ 22+ For engines that do not provide `.__express` out of the box,23+ or if you wish to "map" a different extension to the template engine24+ you may use this method. For example mapping the EJS template engine to25+ ".html" files26+ 27 app.engine('html', require('ejs').renderFile);28 29 In this case EJS provides a `.renderFile()` method with21- the same signature that Express expects: `(path, options, callback)`.30+ the same signature that Express expects: `(path, options, callback)`,31+ though note that it aliases this method as `ejs.__express` internally32+ so if you're using ".ejs" extensions you dont need to do anything.33 34 Some template engines do not follow this convention, the35 [Consolidate.js](https://github.com/visionmedia/consolidate.js)36 library was created to map all of node's popular template474 unmodified linesmodified:lib/application.js+15 added-4 removed
150 unmodified lines151 };152 153 /**154 * Register the given template engine callback `fn`155- * as `ext`. For example if you wanted to map the EJS156- * template engine to ".html" files, rather than ".ejs" files,157- * you could do the following.155+ * as `ext`.156 *157+ * By default will `require()` the engine based on the158+ * file extension. For example if you try to render159+ * a "foo.jade" file Express will invoke the following internally:160+ *161+ * app.engine('jade', require('jade').__express);162+ *163+ * For engines that do not provide `.__express` out of the box,164+ * or if you wish to "map" a different extension to the template engine165+ * you may use this method. For example mapping the EJS template engine to166+ * ".html" files167+ *168 * app.engine('html', require('ejs').renderFile);169 *170 * In this case EJS provides a `.renderFile()` method with162- * the same signature that Express expects: `(path, options, callback)`.171+ * the same signature that Express expects: `(path, options, callback)`,172+ * though note that it aliases this method as `ejs.__express` internally173+ * so if you're using ".ejs" extensions you dont need to do anything.174 *175 * Some template engines do not follow this convention, the176 * [Consolidate.js](https://github.com/visionmedia/consolidate.js)177 * library was created to map all of node's popular template368 unmodified lines