Sha256: 5e0ae418374b3d3846fd63fac8011fd46acf6f6c5cc487555565a639fa223e3a

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 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

      private

      def available_views
        %w(index edit show new)
      end

      def handler
        :haml
      end
    end
  end
end

Version data entries

3 entries across 2 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/haml-rails-2.1.0/lib/generators/haml/scaffold/scaffold_generator.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/haml-rails-2.1.0/lib/generators/haml/scaffold/scaffold_generator.rb
haml-rails-2.1.0 lib/generators/haml/scaffold/scaffold_generator.rb