Sha256: c50838e391c4d6c8165314601a2e2779bcc3cf51d24a12b9d55dbe4ca1a70604
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require 'rails/generators' module Bootstrapped module Generators class LayoutGenerator < ::Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) desc "This generator generates layout file with navigation." argument :layout_name, :type => :string, :default => "application" argument :layout_type, :type => :string, :default => "fixed", :banner => "*fixed or fluid" attr_reader :app_name, :container_class 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.options[: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}" # Add our own require: end 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems