Sha256: b2d0a2578f8ce1e1a35d84006065f54624f64335fa70b5225e92511167afc85d

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 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 "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

1 entries across 1 versions & 1 rubygems

Version Path
html5-rails-0.1.0 lib/generators/html5/layout/layout_generator.rb