@@ -14,27 +14,26 @@ var Generator = module.exports = function Generator() {
1414util . inherits ( Generator , ScriptBase ) ;
1515
1616Generator . prototype . rewriteAppJs = function ( ) {
17- if ( this . env . options . coffee ) {
18- angularUtils . rewriteFile ( {
19- file : path . join ( this . env . options . appPath , 'scripts/app.coffee' ) ,
20- needle : '.otherwise' ,
21- splicable : [
22- '.when \'/' + this . name + '\',' ,
23- ' templateUrl: \'views/' + this . name + '.html\',' ,
24- ' controller: \'' + this . _ . classify ( this . name ) + 'Ctrl\''
25- ]
26- } ) ;
17+ var coffee = this . env . options . coffee ;
18+ var config = {
19+ file : path . join (
20+ this . env . options . appPath ,
21+ 'scripts/app.' + ( coffee ? 'coffee' : 'js' )
22+ ) ,
23+ needle : '.otherwise' ,
24+ splicable : [
25+ " templateUrl: 'views/" + this . name + ".html'" + ( coffee ? "" : "," ) ,
26+ " controller: '" + this . _ . classify ( this . name ) + "Ctrl'"
27+ ]
28+ } ;
29+
30+ if ( coffee ) {
31+ config . splicable . unshift ( ".when '/" + this . name + "'," ) ;
2732 }
2833 else {
29- angularUtils . rewriteFile ( {
30- file : path . join ( this . env . options . appPath , 'scripts/app.js' ) ,
31- needle : '.otherwise' ,
32- splicable : [
33- '.when(\'/' + this . name + '\', {' ,
34- ' templateUrl: \'views/' + this . name + '.html\',' ,
35- ' controller: \'' + this . _ . classify ( this . name ) + 'Ctrl\'' ,
36- '})'
37- ]
38- } ) ;
34+ config . splicable . unshift ( ".when('/" + this . name + "', {" ) ;
35+ config . splicable . push ( "})" ) ;
3936 }
37+
38+ angularUtils . rewriteFile ( config ) ;
4039} ;
0 commit comments