Sha256: 4473251e368aa9d60ccf34bba84df444f1e7c4e5665cd8869ad3df55059175c7

Contents?: true

Size: 680 Bytes

Versions: 6

Compression:

Stored size: 680 Bytes

Contents

require "fileutils"

class ViewGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)
  argument :actions, type: :array, required: false, default: [], desc: "The pages to generate"

  def create_root_directory
    empty_directory(File.join("app/views", file_name)) if actions.empty?
  end

  def create_view_file
    unless actions.empty?
      actions.each do |filename|
        template("view.html.erb", File.join("app/views", class_path, file_name, "#{filename}.html.erb"))
      end
    end
  end

  def generate_locale_file
    invoke("locale:view", [name]) if ActiveGenerator.configuration.autoload_view_generator_locale
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
active_generator-2.2.4 lib/generators/view/view_generator.rb
active_generator-2.2.3 lib/generators/view/view_generator.rb
active_generator-2.2.2 lib/generators/view/view_generator.rb
active_generator-2.2.1 lib/generators/view/view_generator.rb
active_generator-2.2.0 lib/generators/view/view_generator.rb
active_generator-2.1.0 lib/generators/view/view_generator.rb