Permalink
Browse files

Split controller and array controller templates

  • Loading branch information...
1 parent 3970791 commit 7e1fbc7985560977ab95f600da97fb7236a8048b tomhuda committed Apr 14, 2012
@@ -9,7 +9,12 @@ class ControllerGenerator < ::Rails::Generators::NamedBase
class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
def create_controller_files
- template 'controller.js', File.join('app/assets/javascripts/ember/controllers', class_path, "#{file_name}_controller.js")
+ file_path = File.join('app/assets/javascripts/ember/controllers', class_path, "#{file_name}_controller.js")
+ if options.array?
+ template 'array_controller.js', file_path
+ else
+ template 'controller.js', file_path
+ end
end
end
end
@@ -0,0 +1,10 @@
+<%= application_name.camelize %>.<%= class_name %>Controller = Ember.ArrayController.extend({
+ /**
+ You can set the content of the ArrayController to any object that implements
+ Ember.Array. You can bind your views to this controller, then change the array
+ represented by it at any time; your views will update automatically.
+ */
+ content: null
+});
+
+<%= application_name.camelize %>.<%= class_name.camelize(:lower) %>Controller = <%= application_name.camelize %>.<%= class_name %>Controller.create();
@@ -1,5 +1,5 @@
-<%= application_name.camelize %>.<%= class_name %>Controller = Ember.<%= options.array? ? "ArrayController" : "Object" %>.extend({
- // Implement your controller here.
+<%= application_name.camelize %>.<%= class_name %>Controller = Ember.Object.extend({
+ // Implement your controller here.
});
<%= application_name.camelize %>.<%= class_name.camelize(:lower) %>Controller = <%= application_name.camelize %>.<%= class_name %>Controller.create();

0 comments on commit 7e1fbc7

Please sign in to comment.