Sha256: 9de844c26d45105f34334b6b7d5c80e3fe1ca2de52c1fd640186ed29cef6402f

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 Bytes

Contents

require 'rails/generators/erb/scaffold/scaffold_generator'

module Haml
  module Generators
    class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
      source_root File.expand_path("../templates", __FILE__)

      def copy_view_files
        available_views.each do |view|
          filename = filename_with_extensions(view)
          template "#{view}.html.haml", File.join("app/views", controller_file_path, filename)
        end
      end

      hook_for :form_builder, :as => :scaffold

      def copy_form_file
        if options[:form_builder].nil?
          filename = filename_with_extensions("_form")
          template "_form.html.haml", File.join("app/views", controller_file_path, filename)
        end
      end

      protected

      def available_views
        %w(index edit show new)
      end

      def handler
        :haml
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hamlit-rails-0.2.3 lib/generators/haml/scaffold/scaffold_generator.rb
hamlit-rails-0.2.2 lib/generators/haml/scaffold/scaffold_generator.rb
hamlit-rails-0.2.1 lib/generators/haml/scaffold/scaffold_generator.rb
hamlit-rails-0.2.0 lib/generators/haml/scaffold/scaffold_generator.rb
hamlit-rails-0.1.0 lib/generators/haml/scaffold/scaffold_generator.rb