Sha256: 604ef49e420ed58db3ce3c4b91687b309577ca4cc6b442c2a1d1be00e3db02ab

Contents?: true

Size: 997 Bytes

Versions: 80

Compression:

Stored size: 997 Bytes

Contents

module Scrivito
  module Generators
    class PageGenerator < ::Rails::Generators::NamedBase
      source_root File.expand_path('../templates', __FILE__)

      argument :name, type: :string
      argument :attributes, type: :array, default: [], banner: 'attribute:type attribute:type'

      def create_model
        template 'model.erb', "app/models/#{file_name}.rb"
      end

      def create_controller
        template 'controller.erb', "app/controllers/#{file_name}_controller.rb"
      end

      def create_views
        copy_file 'index.html.erb', "app/views/#{file_name}/index.html.erb"
        copy_file 'details.html.erb', "app/views/#{file_name}/details.html.erb"
        template 'thumbnail.html.erb', "app/views/#{file_name}/thumbnail.html.erb"
      end

      def file_name
        super.ends_with?('page') ? super : "#{super}_page"
      end

      def class_name
        super.ends_with?('page') || super.ends_with?('Page') ? super : "#{super}Page"
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
scrivito_sdk-1.17.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.17.0.rc3 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.17.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.17.0.rc1 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.16.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.16.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.16.0.rc1 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.15.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.15.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.15.0.rc1 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.14.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.14.0.rc3 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.14.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.14.0.rc1 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.13.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.13.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.13.0.rc1 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.12.0 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.12.0.rc2 lib/generators/scrivito/page/page_generator.rb
scrivito_sdk-1.12.0.rc1 lib/generators/scrivito/page/page_generator.rb