Permalink
Browse files

Fix attempt #2 for crud generators

  • Loading branch information...
1 parent 599f3c0 commit 01523be33de030db458abbeeb0ecd21f8981611c @addyosmani addyosmani committed Jan 16, 2013
Showing with 12 additions and 2 deletions.
  1. +12 −2 generators/angularcrud/crud-route/index.js
@@ -2,13 +2,23 @@
var path = require('path'),
util = require('util'),
grunt = require('grunt'),
- _ = grunt.util._,
yeoman = require('yeoman'),
angularUtils = require('../util.js');
module.exports = Generator;
+
+function titleize(str){
+ if (str == null) return '';
+ return String(str).replace(/(?:^|\s)\S/g, function(c){ return c.toUpperCase(); });
+}
+
+function classify(str){
+ return titleize(String(str).replace(/[\W_]/g, ' ')).replace(/\s/g, '');
+}
+
function Generator() {
+
yeoman.generators.NamedBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));
@@ -41,7 +51,7 @@ Generator.prototype.rewriteAppJs = function() {
splicable: [
".when('/api/" + this.name + "/" + this.action + "', {",
" templateUrl: 'views/" + this.name + "/" + this.filename + ".html',",
- " controller: '" + _.classify(this.filename) + "Ctrl'",
+ " controller: '" + classify(this.filename) + "Ctrl'",
"})"
]
});

0 comments on commit 01523be

Please sign in to comment.