Skip to content
Browse files

Update the generators and files to use the new Router API.

  • Loading branch information...
1 parent 97e4430 commit 44787ea5f8ed225b55d83cf135527857a9057530 @patr1ck patr1ck committed May 29, 2012
View
10 lib/generators/ember/bootstrap_generator.rb
@@ -30,7 +30,7 @@ def inject_ember
end
def create_dir_layout
- %W{models controllers views states helpers templates}.each do |dir|
+ %W{models controllers views routes helpers templates}.each do |dir|
empty_directory "#{ember_path}/#{dir}"
create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
end
@@ -40,8 +40,12 @@ def create_app_file
template "app.js", "#{ember_path}/#{application_name.underscore}.js"
end
- def create_state_manager_file
- template "states.js", "#{ember_path}/states/app_states.js"
+ def create_router_file
+ template "router.js", "#{ember_path}/routes/app_router.js"
+ end
+
+ def create_app_template
+ template "application.handlebars", "#{ember_path}/templates/application.handlebars"
end
def inject_proper_ember_version
View
8 lib/generators/templates/app.js
@@ -6,12 +6,10 @@
//= require_tree ./states
//= require_self
-// <%= application_name.camelize %>.stateManager is useful for debugging,
-// but don't use it directly in application code.
-var stateManager = <%= application_name.camelize %>.stateManager = <%= application_name.camelize %>.StateManager.create();
-<%= application_name.camelize %>.initialize(stateManager);
+var router = <%= application_name.camelize %>.router = <%= application_name.camelize %>.Router.create();
+<%= application_name.camelize %>.initialize(router);
jQuery(function() {
- stateManager.send('ready');
+ router.send('ready');
});
View
3 lib/generators/templates/application.handlebars
@@ -0,0 +1,3 @@
+<h1><%= application_name %></h1>
+
+{{outlet}}
View
2 lib/generators/templates/array_controller.js
@@ -2,6 +2,6 @@
// Implement your controller here.
//
// An ArrayController has a `content` property, which you should
- // set up in your state manager.
+ // set up in your router.
});
View
2 lib/generators/templates/controller.js
@@ -1,4 +1,4 @@
-<%= application_name.camelize %>.<%= class_name %>Controller = Ember.Object.extend({
+<%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
// Implement your controller here.
});
View
16 lib/generators/templates/router.js
@@ -0,0 +1,16 @@
+<%= application_name.camelize %>.Router = Ember.Router.extend({
+ root: Ember.State.extend({
+ index: Ember.State.extend({
+ route: '/'
+
+ // You'll likely want to connect a view here.
+ // connectOutlets: function(router) {
+ // router.get('applicationController').connectOutlet(App.MainView);
+ // }
+
+ // Layout your routes here...
+
+ })
+ })
+});
+
View
18 lib/generators/templates/states.js
@@ -1,18 +0,0 @@
-<%= application_name.camelize %>.StateManager = Ember.StateManager.extend({
- initialState: 'bootstrap',
-
- states: {
- bootstrap: Ember.State.extend({
- ready: function(manager) {
- // put your bootstrap logic here
- var store = DS.Store.create({
- adapter: DS.RESTAdapter.create(),
- revision: 4
- });
-
- manager.set('store', store);
- }
- })
- }
-});
-

1 comment on commit 44787ea

@frodsan

@patr1ck what about an application_controller.js template?

Please sign in to comment.
Something went wrong with that request. Please try again.