fixed register
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 065c37c · Browse files · 2 files·+35 added−29 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+35 added−29 removed
- other:+35 added−29 removed
Provenance
- Commit
6b2c3ca- Tree
998cc46- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
065c37c
2 files changed+35 added−29 removed
modified:lib/express/view/view.js+33 added
102 unmodified linesExpand all103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139102 unmodified linesExpand allView.prototype.__defineGetter__('templateEngine', function(){ var ext = this.extension; return cache[ext] || (cache[ext] = require(this.engine));});
/** * Register the given template engine `exports` * as `ext`. For example we may wish to map ".html" * files to jade: * * app.register('.html', require('jade')); * * This is also useful for libraries that may not * match extensions correctly. For example my haml.js * library is installed from npm as "hamljs" so instead * 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. * * app.register('.foo', { * render: function(str, options) { * // perhaps their api is * // return foo.toHTML(str, options); * } * }); * * @param {String} ext * @param {Object} obj * @api public */
exports.register = function(ext, exports) { cache[ext] = exports;};modified:lib/express/view.js+2 added-29 removed
34 unmodified lines35 exports = module.exports = View;36 exports.Partial = Partial;37 38 /**39- * Register the given template engine `exports`40- * as `ext`. For example we may wish to map ".html"41- * files to jade:42- *43- * app.register('.html', require('jade'));44- *45- * This is also useful for libraries that may not46- * match extensions correctly. For example my haml.js47- * library is installed from npm as "hamljs" so instead48- * of layout.hamljs, we can register the engine as ".haml":49- *50- * app.register('.haml', require('haml-js'));51- *52- * For engines that do not comply with the Express53- * specification, we can also wrap their api this way.54- *55- * app.register('.foo', {56- * render: function(str, options) {57- * // perhaps their api is58- * // return foo.toHTML(str, options);59- * }60- * });61- *62- * @param {String} ext63- * @param {Object} obj64- * @api public39+ * Export template engine registrar.40 */41 67-exports.register = function(ext, exports) {68- cache[ext] = exports;69-};42+exports.register = View.register;43 44 /**45 * Render `view` partial with the given `options`.46 *200 unmodified lines