Class: Bootstrapped::Generators::LayoutGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Bootstrapped::Generators::LayoutGenerator
- Defined in:
- lib/generators/bootstrapped/layout/layout_generator.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#container_class ⇒ Object
readonly
Returns the value of attribute container_class.
Instance Method Summary collapse
- #application_controller_should_default_use_newly_generated_layout ⇒ Object
- #generate_layout ⇒ Object
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
12 13 14 |
# File 'lib/generators/bootstrapped/layout/layout_generator.rb', line 12 def app_name @app_name end |
#container_class ⇒ Object (readonly)
Returns the value of attribute container_class.
12 13 14 |
# File 'lib/generators/bootstrapped/layout/layout_generator.rb', line 12 def container_class @container_class end |
Instance Method Details
#application_controller_should_default_use_newly_generated_layout ⇒ Object
26 27 28 29 30 31 |
# File 'lib/generators/bootstrapped/layout/layout_generator.rb', line 26 def application_controller_should_default_use_newly_generated_layout layout_name_here = %Q{ layout \'#{layout_name}\'\n} insert_into_file('app/controllers/application_controller.rb', after: "protect_from_forgery\n") do layout_name_here end end |
#generate_layout ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/bootstrapped/layout/layout_generator.rb', line 14 def generate_layout app = ::Rails.application @app_name = app.class.to_s.split("::").first @container_class = layout_type == "fluid" ? "container-fluid" : "container" ext = app.config.generators.[:rails][:template_engine] || :erb template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}" template "_bootstrapped-navigation.html.#{ext}", "app/views/layouts/_bootstrapped-navigation.html.#{ext}" template '_apple_icon.html.erb', "app/views/layouts/_apple_icon.html.#{ext}" template '_sidebar.html.erb', "app/views/layouts/_sidebar.html.#{ext}" # Add our own require: end |