removed old view.js
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 e904132 · Browse files · 2 files·+0 added−103 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+0 added−103 removed
- other:+0 added−103 removed
Provenance
- Commit
cecbaf2- Tree
3881466- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
e904132
2 files changed+0 added−103 removed
modified:lib/application.js-1 removed
583 unmodified lines584 if (!ext) return fn(new Error('failed to find view "' + view + '"'));585 586 // render587 try {588- console.log(engines);588 var engine = engines[ext] = engines[ext] || require(ext);589 options.filename = join(root, view);590 view = fs.readFileSync(options.filename, 'utf8');591 engine.render(view, options, fn);4 unmodified linesdeleted:lib/view.js-102 removed
1-2-/*!3- * Express - view4- * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5- * MIT Licensed6- */7-8-/**9- * Module dependencies.10- */11-12-var path = require('path')13- , extname = path.extname14- , join = path.join15- , utils = require('connect').utils16- , union = require('./utils').union17- , merge = utils.merge18- , http = require('http')19- , fs = require('fs')20- , res = http.ServerResponse.prototype;21-22-/**23- * Render `view` with the given `options` and optional callback `fn`.24- * When a callback function is given a response will _not_ be made25- * automatically, otherwise a response of _200_ and _text/html_ is given.26- *27- * Options:28- * 29- * - `status` Response status code (`res.statusCode`)30- * - `charset` Set the charset (`res.charset`)31- *32- * Reserved locals:33- *34- * - `cache` boolean hinting to the engine it should cache35- * - `filename` filename of the view being rendered36- *37- * @param {String} view38- * @param {Object|Function} options or callback function39- * @param {Function} fn40- * @api public41- */42-43-res.render = function(view, opts, fn){44- var self = this45- , options = {}46- , app = this.app47- , req = this.req48- , cache = app.cache49- , engines = app.engines50- , root = app.set('views') || process.cwd() + '/views';51-52- // support callback function as second arg53- if ('function' == typeof opts) {54- fn = opts, opts = null;55- }56-57- // merge app.locals58- union(options, app.locals);59-60- // merge res.locals61- merge(options, this.locals);62-63- // merge render() options64- if (opts) merge(options, opts);65-66- // status support67- if (options.status) this.statusCode = options.status;68-69- // charset option70- if (options.charset) this.charset = options.charset;71-72- // join "view engine" if necessary73- var ext = extname(view);74- if (!ext) view += '.' + (ext = app.set('view engine'));75-76- // pass .cache to the engine77- options.cache = app.enabled('view cache');78-79- // when no extension nor "view engine" is given warn80- if (!ext) {81- console.warn('Warning: cannot determine view engine for "%s"', view);82- console.warn('provide the "view engine" setting or an');83- console.warn('extension such as "foo.jade".');84- return this.end();85- }86-87- // callback88- fn = fn || function(err, str){89- if (err) return req.next(err);90- self.send(str);91- };92-93- // render94- try {95- var engine = cache[ext] = cache[ext] || require(ext);96- options.filename = join(root, view);97- view = fs.readFileSync(options.filename, 'utf8');98- engine.render(view, options, fn);99- } catch (err) {100- fn(err);101- }102-};