lib/builder.js
function (combinations, parts, backboneSrc) {
    var src = '';
    var allCombinations = [];

    parts.forEach(function (part) {
      allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
    });

    var neededParts = _.union.apply(_, allCombinations);
    var backboneParts = getBackboneParts(backboneSrc);
    var finalCombination = _.intersection(combinations.All, neededParts);

    finalCombination.forEach(function (part) {
      src += backboneParts[_.str.capitalize(part.toLowerCase())];

      if (part.toLowerCase() === 'view') {
        src = src.replace('Model.extend = Collection.extend = Router.extend = View.extend = extend;', '');
      }
    });

    var extender = '';
    if(!_.contains(finalCombination, 'View') && !_.contains(finalCombination, 'view')) {
      extender += '  var extend = function (protoProps, classProps) {\n';
      extender += '    var child = inherits(this, protoProps, classProps)\n';
      extender += '    child.extend = this.extend;\n';
      extender += '    return child;\n';
      extender += '  };\n\n';
    }

    // add the extend chain
    finalCombination.forEach(function (extendo) {
      var lowerEx = extendo.toLowerCase();
      if (lowerEx === 'model') {
        extender += 'Model.extend = ';
      }

      if (lowerEx === 'collection') {
        extender += 'Collection.extend = ';
      }

      if (lowerEx === 'router') {
        extender += 'Router.extend = ';
      }

      if (lowerEx === 'view') {
        extender += 'View.extend = ';
      }
    });

    extender += 'extend;';

    src = src.replace('// Helpers', extender + '\n\n  // Helpers');

    return src;
  }
function (combinations, parts, backboneSrc) {
    var src = '';
    var allCombinations = [];

    parts.forEach(function (part) {
      allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
    });

    var neededParts = _.union.apply(_, allCombinations);
    var backboneParts = getBackboneParts(backboneSrc);
    var finalCombination = _.intersection(combinations.All, neededParts);

    finalCombination.forEach(function (part) {
      src += backboneParts[_.str.capitalize(part.toLowerCase())];

      if (part.toLowerCase() === 'view') {
        src = src.replace('Model.extend = Collection.extend = Router.extend = View.extend = extend;', '');
      }
    });

    var extender = '';
    if(!_.contains(finalCombination, 'View') && !_.contains(finalCombination, 'view')) {
      extender += '  var extend = function (protoProps, classProps) {\n';
      extender += '    var child = inherits(this, protoProps, classProps)\n';
      extender += '    child.extend = this.extend;\n';
      extender += '    return child;\n';
      extender += '  };\n\n';
    }

    // add the extend chain
    finalCombination.forEach(function (extendo) {
      var lowerEx = extendo.toLowerCase();
      if (lowerEx === 'model') {
        extender += 'Model.extend = ';
      }

      if (lowerEx === 'collection') {
        extender += 'Collection.extend = ';
      }

      if (lowerEx === 'router') {
        extender += 'Router.extend = ';
      }

      if (lowerEx === 'view') {
        extender += 'View.extend = ';
      }
    });

    extender += 'extend;';

    src = src.replace('// Helpers', extender + '\n\n  // Helpers');

    return src;
  }
function ( combinations , parts , backboneSrc ) { var src = '' ; var allCombinations = [ ] ; parts . forEach ( function ( part ) { allCombinations . push ( combinations [ _ . str . capitalize ( part . toLowerCase ( ) ) ] ) ; } ) ; var neededParts = _ . union . apply ( _ , allCombinations ) ; var backboneParts = getBackboneParts ( backboneSrc ) ; var finalCombination = _ . intersection ( combinations . All , neededParts ) ; finalCombination . forEach ( function ( part ) { src += backboneParts [ _ . str . capitalize ( part . toLowerCase ( ) ) ] ; if ( part . toLowerCase ( ) === 'view' ) { src = src . replace ( 'Model.extend = Collection.extend = Router.extend = View.extend = extend;' , '' ) ; } } ) ; var extender = '' ; if ( ! _ . contains ( finalCombination , 'View' ) && ! _ . contains ( finalCombination , 'view' ) ) { extender += '  var extend = function (protoProps, classProps) {\n' ; extender += '    var child = inherits(this, protoProps, classProps)\n' ; extender += '    child.extend = this.extend;\n' ; extender += '    return child;\n' ; extender += '  };\n\n' ; } // add the extend chain finalCombination . forEach ( function ( extendo ) { var lowerEx = extendo . toLowerCase ( ) ; if ( lowerEx === 'model' ) { extender += 'Model.extend = ' ; } if ( lowerEx === 'collection' ) { extender += 'Collection.extend = ' ; } if ( lowerEx === 'router' ) { extender += 'Router.extend = ' ; } if ( lowerEx === 'view' ) { extender += 'View.extend = ' ; } } ) ; extender += 'extend;' ; src = src . replace ( '// Helpers' , extender + '\n\n  // Helpers' ) ; return src ; }
glues the backbone parts together again
glues the backbone parts together again