Removed Partial constructor (not used)
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 2007407 · Browse files · 3 files·+9 added−63 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+9 added−63 removed
- tests:+3 added−22 removed
- other:+6 added−41 removed
Provenance
- Commit
d7488bb- Tree
8781c06- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
2007407
3 files changed+9 added−63 removed
modified:lib/view/partial.js-26 removed
4 unmodified lines5678910111213141591011121314222324252627282930313233343536373839401516171822 unmodified lines4 unmodified lines * MIT Licensed */
/** * Module dependencies. */
var View = require('./view') , basename = require('path').basename;
/** * Memory cache. */
var cache = {};
/** * Initialize a new `Partial` for the given `view` and `options`. * * @param {String} view * @param {Object} options * @api private */
var Partial = exports = module.exports = function Partial(view, options) { options = options || {}; View.call(this, view, options);};
/** * Inherit from `View.prototype`. */
Partial.prototype.__proto__ = View.prototype;
/** * Resolve partial object name from the view path. * * Examples: *22 unmodified linesmodified:lib/view.js+6 added-15 removed
13 unmodified lines14 , dirname = path.dirname15 , basename = path.basename16 , utils = require('connect').utils17 , View = require('./view/view')18- , Partial = require('./view/partial')18+ , partial = require('./view/partial')19 , union = require('./utils').union20 , merge = utils.merge21 , http = require('http')22 , res = http.ServerResponse.prototype;10 unmodified lines33 * Expose constructors.34 */35 36 exports = module.exports = View;37-exports.Partial = Partial;37 38 /**39 * Export template engine registrar.40 */35 unmodified lines76 options.renderPartial = true;77 options.layout = false;78 79 // Deduce name from view path81- var name = options.as || Partial.resolveObjectName(view);80+ var name = options.as || partial.resolveObjectName(view);81 82 // Render partial83 function render(){84 if (options.object) {137 unmodified lines222 options.defaultEngine = app.set('view engine');223 224 // Populate view225 // TODO: move this logic into the protos227- var orig = view = partial228- ? new Partial(view, options)229- : new View(view, options);226+ var orig = view = new View(view, options);227 228 // Ensure view exists, otherwise try _ prefix229 if (!view.exists) {233- view = partial234- ? new Partial(view.prefixPath, options)235- : new View(view.prefixPath, options);230+ view = new View(view.prefixPath, options);231 }232 233 // Ensure view _ prefix exists, otherwise try index234 if (!view.exists) {240- view = partial241- ? new Partial(orig.indexPath, options)242- : new View(orig.indexPath, options);235+ view = new View(orig.indexPath, options);236 }237 238 // Ensure view exists, or try ../index239 if (!view.exists && !options.isLayout) {247- view = partial248- ? new Partial(orig.upIndexPath, options)249- : new View(orig.upIndexPath, options);240+ view = new View(orig.upIndexPath, options);241 }242 243 // Dynamic helper support244 if (false !== options.dynamicHelpers) {57 unmodified linesmodified:test/view.test.js+3 added-22 removed
6 unmodified lines7 , connect = require('connect')8 , assert = require('assert')9 , should = require('should')10 , View = require('../lib/view')11- , Partial = View.Partial11+ , partial = require('../lib/view/partial')12 13 /**14 * Create a test server with views set to ./fixtures.15 */76 unmodified lines92 var view = new View(__dirname + '/fixtures/hello.jade');93 view.templateEngine.should.equal(require('jade'));94 },95 96- 'test Partial.resolveObjectName()': function(){97- var resolve = Partial.resolveObjectName;96+ 'test partial.resolveObjectName()': function(){97+ var resolve = partial.resolveObjectName;98 resolve('/path/to/user.ejs').should.equal('user');99 resolve('/path/to/user-post.ejs').should.equal('userPost');100 resolve('/path/to/user post.ejs').should.equal('userPost');101 resolve('forum thread post.ejs').should.equal('forumThreadPost');102 resolve('forum thread post.ejs').should.equal('forumThreadPost');103 },104 105- 'test Partial#path for partials': function(){106- var fixtures = __dirname + '/fixtures';107- 108- var view = new Partial('user.jade', { root: fixtures });109- view.path.should.equal(fixtures + '/user.jade');110-111- var view = new Partial('user', { parentView: view, root: fixtures });112- view.path.should.equal(fixtures + '/user.jade');113- 114- var view = new Partial('forum/thread', { parentView: view });115- view.path.should.equal(fixtures + '/forum/thread.jade');116-117- var view = new Partial('forum/thread.jade', { root: fixtures });118- view.path.should.equal(fixtures + '/forum/thread.jade');119-120- var view = new Partial('thread', { parentView: view });121- view.path.should.equal(fixtures + '/forum/thread.jade');122- },123-105 'test #render()': function(){106 var app = create();107 app.set('view engine', 'jade');108 779 unmodified lines