Sha256: 6b516bf87c6090ae69d1ceb953b4ef9301288b5337b6b4bb03f538ccaecf1b3c

Contents?: true

Size: 941 Bytes

Versions: 62

Compression:

Stored size: 941 Bytes

Contents

module Workarea
  class ProductTemplateGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)
    class_option 'skip-view-model', type: :boolean

    def add_template_to_workarea_initializer
      inject_into_file 'config/initializers/workarea.rb', before: "\nend" do
        "\n\n\s\sconfig.product_templates << :#{file_name}"
      end
    end

    def create_partial_template
      target_path = 'app/views/workarea/storefront/products/templates/'
      target_path += "_#{file_name}.html.haml"
      copy_file "#{Storefront::Engine.root}/app/views/workarea/storefront/products/templates/_generic.html.haml", target_path
    end

    def create_view_model
      return if options['skip-view-model']

      target_path = 'app/view_models/workarea/storefront/product_templates/'
      target_path += "#{file_name}_view_model.rb"
      template 'view_model.rb.erb', target_path
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.15 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.36 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.14 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.35 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.13 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.34 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.12 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.33 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.11 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.10 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.32 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.9 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.31 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.8 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.30 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.7 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.29 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.6 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.28 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.5 lib/generators/workarea/product_template/product_template_generator.rb