Sha256: 9d856c5fbae17aa445c71c62df0c37f2fef1a02ef9c65b38db0ba115b29344a4

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

class ComponentGenerator < Rails::Generators::Base
  argument :component_name, required: true, desc: "Component name, e.g: button"

  def create_view_file
    create_file "#{component_path}/_#{component_name}.html.erb"
  end

  def create_css_file
    create_file "#{component_path}/#{component_name}.css"
  end

  def create_js_file
    create_file "#{component_path}/#{component_name}.js" do
      # require component's CSS inside JS automatically
      "import \"./#{component_name}.css\";\n"
    end
  end

  protected

  def component_path
    "frontend/components/#{component_name}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tractor_beam-0.1.4 templates/component_generator
tractor_beam-0.1.2 templates/component_generator
tractor_beam-0.1.1 templates/component_generator