Sha256: 7a106cae57057b23ddb46389212eb8ec7accbda0c99b622496cd4688099ac0b3

Contents?: true

Size: 954 Bytes

Versions: 6

Compression:

Stored size: 954 Bytes

Contents

require 'generators/nifty'

module Nifty
  module Generators
    class LayoutGenerator < Base
      argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'

      class_option :haml, :desc => 'Generate HAML for view, and SASS for stylesheet.', :type => :boolean

      def create_layout
        if options.haml?
          template 'layout.html.haml', "app/views/layouts/#{file_name}.html.haml"
          copy_file 'stylesheet.sass', "public/stylesheets/sass/#{file_name}.sass"
        else
          template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb"
          copy_file 'stylesheet.css', "public/stylesheets/#{file_name}.css"
        end
        copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
        copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb'
      end

      private

      def file_name
        layout_name.underscore
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nifty-generators-0.4.6 lib/generators/nifty/layout/layout_generator.rb
nifty-generators-0.4.5 lib/generators/nifty/layout/layout_generator.rb
nifty-generators-0.4.4 lib/generators/nifty/layout/layout_generator.rb
nifty-generators-0.4.3 lib/generators/nifty/layout/layout_generator.rb
nifty-generators-0.4.2 lib/generators/nifty/layout/layout_generator.rb
nifty-generators-0.4.1 lib/generators/nifty/layout/layout_generator.rb