lib/application.js
function buildPartialView(path) {

  var self = this;
  var layoutPrefix = /^layout_/;
  var p = pathModule.basename(path);
  var pos = p.indexOf('.');
  var ext = p.slice(pos+1);
  
  if (ext in this.enginesByExtension) {
        
    var engine = this.enginesByExtension[ext];
    var func = engine.renderPartial(path);

    var id = path
      .replace(this.mvcpath + 'views/', '')
      .replace('/partials/', '/')
      .replace(/\/+/g, '_')
      .replace(/[_\-]+/g, '_')
      .replace(/^_+/g, '');

    // Note: the layout_ prefix needs to be removed from the name because
    // the slash from the path has been replaced with an underscore.

    id = id.slice(0, id.indexOf('.')).toLowerCase().replace(layoutPrefix, '');

    // Normalize views to remove duplicate chunks within the filename
    // For example: dashboard/dashboard-test will be accessed as {{> dashboard_test}}
    // The added benefit of this method is that it will remove all duplicate subsequent
    // occurrences of the same chunk, regardless.
    id = id.split('_').reduce(function(prev, current) {
      if (prev[0] !== current) prev.unshift(current);
      return prev;
    }, []).reverse().join('_');
    
    func.id = id;

    this.views.partials[id] = func;
    
  } else {
    
    throw new Error(util.format("Unable to render %s: engine not loaded",  this.relPath(path)));
    
  }

}
function buildPartialView(path) {

  var self = this;
  var layoutPrefix = /^layout_/;
  var p = pathModule.basename(path);
  var pos = p.indexOf('.');
  var ext = p.slice(pos+1);
  
  if (ext in this.enginesByExtension) {
        
    var engine = this.enginesByExtension[ext];
    var func = engine.renderPartial(path);

    var id = path
      .replace(this.mvcpath + 'views/', '')
      .replace('/partials/', '/')
      .replace(/\/+/g, '_')
      .replace(/[_\-]+/g, '_')
      .replace(/^_+/g, '');

    // Note: the layout_ prefix needs to be removed from the name because
    // the slash from the path has been replaced with an underscore.

    id = id.slice(0, id.indexOf('.')).toLowerCase().replace(layoutPrefix, '');

    // Normalize views to remove duplicate chunks within the filename
    // For example: dashboard/dashboard-test will be accessed as {{> dashboard_test}}
    // The added benefit of this method is that it will remove all duplicate subsequent
    // occurrences of the same chunk, regardless.
    id = id.split('_').reduce(function(prev, current) {
      if (prev[0] !== current) prev.unshift(current);
      return prev;
    }, []).reverse().join('_');
    
    func.id = id;

    this.views.partials[id] = func;
    
  } else {
    
    throw new Error(util.format("Unable to render %s: engine not loaded",  this.relPath(path)));
    
  }

}
function buildPartialView ( path ) { var self = this ; var layoutPrefix = / ^layout_ / ; var p = pathModule . basename ( path ) ; var pos = p . indexOf ( '.' ) ; var ext = p . slice ( pos + 1 ) ; if ( ext in this . enginesByExtension ) { var engine = this . enginesByExtension [ ext ] ; var func = engine . renderPartial ( path ) ; var id = path . replace ( this . mvcpath + 'views/' , '' ) . replace ( '/partials/' , '/' ) . replace ( / \/+ / g , '_' ) . replace ( / [_\-]+ / g , '_' ) . replace ( / ^_+ / g , '' ) ; // Note: the layout_ prefix needs to be removed from the name because // the slash from the path has been replaced with an underscore. id = id . slice ( 0 , id . indexOf ( '.' ) ) . toLowerCase ( ) . replace ( layoutPrefix , '' ) ; // Normalize views to remove duplicate chunks within the filename // For example: dashboard/dashboard-test will be accessed as {{> dashboard_test}} // The added benefit of this method is that it will remove all duplicate subsequent // occurrences of the same chunk, regardless. id = id . split ( '_' ) . reduce ( function ( prev , current ) { if ( prev [ 0 ] !== current ) prev . unshift ( current ) ; return prev ; } , [ ] ) . reverse ( ) . join ( '_' ) ; func . id = id ; this . views . partials [ id ] = func ; } else { throw new Error ( util . format ( "Unable to render %s: engine not loaded" , this . relPath ( path ) ) ) ; } }
Builds a partial view and caches its function
Builds a partial view and caches its function