Class: Bootstrap::Generators::ThemedGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Bootstrap::Generators::ThemedGenerator
- Defined in:
- lib/generators/bootstrap/themed/themed_generator.rb
Instance Method Summary collapse
- #copy_form_builder ⇒ Object
- #copy_helper ⇒ Object
- #copy_views ⇒ Object
-
#initialize(args, *options) ⇒ ThemedGenerator
constructor
A new instance of ThemedGenerator.
Constructor Details
#initialize(args, *options) ⇒ ThemedGenerator
Returns a new instance of ThemedGenerator.
13 14 15 16 |
# File 'lib/generators/bootstrap/themed/themed_generator.rb', line 13 def initialize(args, *) super(args, *) initialize_views_variables end |
Instance Method Details
#copy_form_builder ⇒ Object
18 19 20 |
# File 'lib/generators/bootstrap/themed/themed_generator.rb', line 18 def copy_form_builder copy_file "builders/builder.rb", "app/form_builders/bootstrap_form_builder.rb" end |
#copy_helper ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/bootstrap/themed/themed_generator.rb', line 22 def copy_helper if File.exist?('app/helpers/application_helper.rb') insert_into_file "app/helpers/application_helper.rb"," def bootstrap_form_for(object, options = {}, &block) options[:builder] = BootstrapFormBuilder form_for(object, options, &block) end\n", :after => "module ApplicationHelper\n" else copy_file "builders/helper.rb", "app/helpers/application_helper.rb" end end |
#copy_views ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/generators/bootstrap/themed/themed_generator.rb', line 33 def copy_views generate_views gsub_file(File.join('app/views/layouts', "#{layout}.html.erb"), /\<ul\s+class=\"nav\">.*\<\/ul\>/mi) do |match| match.gsub!(/\<\/ul\>/, "") %|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>| end end |