Skip to content
Myr

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

2 files+0 added−103 removed

modified:lib/application.js-1 removed
583 unmodified lines
584 if (!ext) return fn(new Error('failed to find view "' + view + '"'));585586 // 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 lines
deleted:lib/view.js-102 removed
12/*!3 * Express - view4 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Module dependencies.10 */1112var 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;2122/**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 */4243res.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';5152 // support callback function as second arg53 if ('function' == typeof opts) {54 fn = opts, opts = null;55 }5657 // merge app.locals58 union(options, app.locals);5960 // merge res.locals61 merge(options, this.locals);6263 // merge render() options64 if (opts) merge(options, opts);6566 // status support67 if (options.status) this.statusCode = options.status;6869 // charset option70 if (options.charset) this.charset = options.charset;7172 // join "view engine" if necessary73 var ext = extname(view);74 if (!ext) view += '.' + (ext = app.set('view engine'));7576 // pass .cache to the engine77 options.cache = app.enabled('view cache');7879 // 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 }8687 // callback88 fn = fn || function(err, str){89 if (err) return req.next(err);90 self.send(str);91 };9293 // 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};