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.27 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.26 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.45 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.25 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.23 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.44 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.22 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.43 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.21 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.42 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.20 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.41 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.19 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.40 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.18 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.39 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.17 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.38 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.5.16 lib/generators/workarea/product_template/product_template_generator.rb
workarea-core-3.4.37 lib/generators/workarea/product_template/product_template_generator.rb