Skip to content

Commit

Permalink
Merge pull request #408 from eddiemonge/refac
Browse files Browse the repository at this point in the history
refactor(route): dry up and refactor code
  • Loading branch information
passy committed Oct 24, 2013
2 parents 94e3eda + 698bfa0 commit 889befb
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,26 @@ var Generator = module.exports = function Generator() {
util.inherits(Generator, ScriptBase);

Generator.prototype.rewriteAppJs = function () {
if (this.env.options.coffee) {
angularUtils.rewriteFile({
file: path.join(this.env.options.appPath, 'scripts/app.coffee'),
needle: '.otherwise',
splicable: [
'.when \'/' + this.name + '\',',
' templateUrl: \'views/' + this.name + '.html\',',
' controller: \'' + this._.classify(this.name) + 'Ctrl\''
]
});
var coffee = this.env.options.coffee;
var config = {
file: path.join(
this.env.options.appPath,
'scripts/app.' + (coffee ? 'coffee' : 'js')
),
needle: '.otherwise',
splicable: [
" templateUrl: 'views/" + this.name + ".html'" + (coffee ? "" : "," ),
" controller: '" + this._.classify(this.name) + "Ctrl'"
]
};

if (coffee) {
config.splicable.unshift(".when '/" + this.name + "',");
}
else {
angularUtils.rewriteFile({
file: path.join(this.env.options.appPath, 'scripts/app.js'),
needle: '.otherwise',
splicable: [
'.when(\'/' + this.name + '\', {',
' templateUrl: \'views/' + this.name + '.html\',',
' controller: \'' + this._.classify(this.name) + 'Ctrl\'',
'})'
]
});
config.splicable.unshift(".when('/" + this.name + "', {");
config.splicable.push("})");
}

angularUtils.rewriteFile(config);
};

0 comments on commit 889befb

Please sign in to comment.