Skip to content
Myr

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

3 files+45 added−12 removed

modified:docs/application.md+15 added-4 removed
modified:docs/express.md+15 added-4 removed
9 unmodified lines
1011# app.engine()1213 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 template
474 unmodified lines
modified:lib/application.js+15 added-4 removed
150 unmodified lines
151};152153/**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 template
368 unmodified lines