Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / jsbuilder / src / generators / controller / Controller.js
diff --git a/jsbuilder/src/generators/controller/Controller.js b/jsbuilder/src/generators/controller/Controller.js
new file mode 100644 (file)
index 0000000..3482fe3
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * @class Ext.generator.Controller
+ * @extends Ext.generator.Base
+ * Generates a Controller file based on a template
+ */
+Ext.generator.Controller = Ext.extend(Ext.generator.Base, {
+
+    generate: function() {
+        var controllerFile = 'app/controllers/' + this.name + '.js';
+        
+        this.headline("Generating the " + this.name + " controller");
+        
+        this.template('Controller', this, controllerFile);
+        this.template('ControllerSpec', this, 'test/unit/controllers/' + this.name + '.js');
+        
+        this.insertInclude(controllerFile, 'sencha-controllers');
+        this.insertInclude('../../' + controllerFile, 'app-controllers', 'test/unit/index.html');
+        this.insertInclude('controllers/' + this.name + '.js', 'spec-controllers', 'test/unit/index.html');
+    },
+    
+    decodeArgs: function(args) {
+        this.name = args[0];
+        this.actions = args.slice(1);
+    }
+});
+
+Ext.regGenerator('controller', Ext.generator.Controller);
+
+load('src/generators/controller/templates/ControllerSpec.js');
+load('src/generators/controller/templates/Controller.js');
\ No newline at end of file