Sha256: 409e810a5e2cfc99dbbf18e855b1c7025efe1a2d8f64e9ed0247e0a27bdf0d69

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

require "generators/html5/generator_helpers"

module Html5
  module Generators
    class LayoutGenerator < ::Rails::Generators::NamedBase
      include Html5::Generators::GeneratorHelpers

      source_root File.expand_path('../templates', __FILE__)

      argument :name, :type => :string,
                      :required => false,
                      :default => "application"

      class_option :all_partials, :type => :boolean,
                                  :default => false,
                                  :desc => "Generate all partials for this layout"

      class_option :minimal_partials, :type => :boolean,
                                      :default => false,
                                      :desc => "Generate minimal partials for this layout"

      class_option :template_engine

      def generate_layout
        if file_path == "application" && options[:template_engine].to_s != "erb"
          remove_file File.join("app/views/layouts/application.html.erb")
        end
        template filename_with_extensions("application"), File.join("app/views/layouts", class_path, filename_with_extensions(file_name))
      end

      def generate_partials
        if options.all_partials?
          invoke "html5:partial", [], { :all => true, :path => file_path,
                                                      :template_engine => options[:template_engine] }
        end

        if options.minimal_partials?
          invoke "html5:partial", [], { :minimal => true, :path => file_path,
                                                          :template_engine => options[:template_engine] }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
html5-rails-0.0.7 lib/generators/html5/layout/layout_generator.rb
html5-rails-0.0.6 lib/generators/html5/layout/layout_generator.rb
html5-rails-0.0.5 lib/generators/html5/layout/layout_generator.rb
html5-rails-0.0.4 lib/generators/html5/layout/layout_generator.rb
html5-rails-0.0.3 lib/generators/html5/layout/layout_generator.rb