Sha256: 5aad70c1238545fd722a127ce7fb1792cb414840f07ce9212542afc851a3d176

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

require 'generators/niftier'

module Niftier
  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

3 entries across 3 versions & 1 rubygems

Version Path
niftier-generators-0.1.2 lib/generators/niftier/layout/layout_generator.rb
niftier-generators-0.1.1 lib/generators/niftier/layout/layout_generator.rb
niftier-generators-0.1.0 lib/generators/niftier/layout/layout_generator.rb