Sha256: d184f33ad91ea3c9f5b8b0b3bb825102601d626b6af4ef6246dcb323bf4c2075

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

require "rails/generators/erb/scaffold/scaffold_generator"

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sc_core-0.0.7 lib/generators/haml/scaffold/scaffold_generator.rb