Skip to content
Myr

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

3 files+9 added−63 removed

modified:lib/view/partial.js-26 removed
modified:lib/view.js+6 added-15 removed
13 unmodified lines
14 , 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 lines
33 * Expose constructors.34 */3536exports = module.exports = View;37exports.Partial = Partial;3738/**39 * Export template engine registrar.40 */
35 unmodified lines
76 options.renderPartial = true;77 options.layout = false;7879 // Deduce name from view path81 var name = options.as || Partial.resolveObjectName(view);80 var name = options.as || partial.resolveObjectName(view);8182 // Render partial83 function render(){84 if (options.object) {
137 unmodified lines
222 options.defaultEngine = app.set('view engine');223224 // 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);227228 // 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 }237238 // 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 }242243 // Dynamic helper support244 if (false !== options.dynamicHelpers) {
57 unmodified lines
modified:test/view.test.js+3 added-22 removed
6 unmodified lines
7 , 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')1213/**14 * Create a test server with views set to ./fixtures.15 */
76 unmodified lines
92 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');110111 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');116117 var view = new Partial('forum/thread.jade', { root: fixtures });118 view.path.should.equal(fixtures + '/forum/thread.jade');119120 var view = new Partial('thread', { parentView: view });121 view.path.should.equal(fixtures + '/forum/thread.jade');122 },123105 'test #render()': function(){106 var app = create();107 app.set('view engine', 'jade');108
779 unmodified lines