Sha256: ec1528f58981cf4c5eb4ff5730cebd594106d0e86770b7170fc0a9da8c1a277a

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

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
      
      def show_locale_warning
        puts 'Remember: you must run rails g haml:locale at least once in order to avoid translation errors'
      end

    protected

      def available_views
        %w(index edit show new)
      end

      def handler
        :haml
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
haml-rails-with-i18n-0.1.3 lib/generators/haml/scaffold/scaffold_generator.rb
haml-rails-with-i18n-0.1.2 lib/generators/haml/scaffold/scaffold_generator.rb
haml-rails-with-i18n-0.1.1 lib/generators/haml/scaffold/scaffold_generator.rb
haml-rails-with-i18n-0.1.0 lib/generators/haml/scaffold/scaffold_generator.rb