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.4.27 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.4 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.26 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.3 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.25 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.2 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.24 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.1 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.23 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.22 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.0 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.21 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.0.beta.1 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.20 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.19 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.18 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.17 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.16 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.15 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.14 lib/generators/workarea/product_template/product_template_generator.rb