Sha256: 8835dc000ef8174d1431c70256debd79ae7cb608f7beab9ae3db92af1463c074
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'generators/ember/generator_helpers' module Ember module Generators class ResourceGenerator < ::Rails::Generators::NamedBase include Ember::Generators::GeneratorHelpers source_root File.expand_path("../../templates", __FILE__) desc "Creates a new Ember.js router, controller, view and template" class_option :skip_route, :type => :boolean, :default => false, :desc => "Don't create route" class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects" class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object" def create_resource_files unless options[:skip_route] invoke('ember:route', [ name.pluralize ], options) inject_into_router_file(name) end invoke('ember:controller', [ name.pluralize ], options) invoke('ember:template', [ name.pluralize ], options) end private def inject_into_router_file(name) router_file = "#{config_path}/router.es6" inject_into_file(router_file, :after => /^.*Router.map\(function\(\) \{*$/) do "\n this.resource('#{name.pluralize}');" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ember-appkit-rails-0.5.0 | lib/generators/ember/resource_generator.rb |