Sha256: 23801b76806f2b8d83329a735e486b4e4add88a952abdb1bb5e184c41cd1913b

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 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 'helper.rb', 'app/helpers/layout_helper.rb'
      end

      no_tasks do
        def file_name
          layout_name.underscore
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
very_nifty_generators-0.2.1 lib/generators/nifty/layout/layout_generator.rb
very_nifty_generators-0.2.0 lib/generators/nifty/layout/layout_generator.rb
very_nifty_generators-0.1.2 lib/generators/nifty/layout/layout_generator.rb
very_nifty_generators-0.1.1 lib/generators/nifty/layout/layout_generator.rb
very_nifty_generators-0.1.0 lib/generators/nifty/layout/layout_generator.rb