Sha256: 7a52ebb3ccdab5983aebd312fcf95bbec00b43e14d128ef93f46c7f3b4115754

Contents?: true

Size: 1.9 KB

Versions: 7

Compression:

Stored size: 1.9 KB

Contents

module Components
  <%- @modules.each do |module_name| %><%= "  "* @indet %>module <%= module_name.camelize %><%- @indet += 1 %>
  <%- end %><%="  "* @indet %>class <%= @file_name %> < React::Component::Base

  <%="  "* @indet %># param :my_param
  <%="  "* @indet %># param param_with_default: "default value"
  <%="  "* @indet %># param :param_with_default2, default: "default value" # alternative syntax
  <%="  "* @indet %># param :param_with_type, type: Hash
  <%="  "* @indet %># param :array_of_hashes, type: [Hash]
  <%="  "* @indet %># collect_all_other_params_as :attributes  #collects all other params into a hash

  <%="  "* @indet %># The following are the most common lifecycle call backs,
  <%="  "* @indet %># the following are the most common lifecycle call backs# delete any that you are not using.
  <%="  "* @indet %># call backs may also reference an instance method i.e. before_mount :my_method

  <%="  "* @indet %>before_mount do
  <%="  "* @indet %>  # any initialization particularly of state variables goes here.
  <%="  "* @indet %>  # this will execute on server (prerendering) and client.
  <%="  "* @indet %>end

  <%="  "* @indet %>after_mount do
  <%="  "* @indet %>  # any client only post rendering initialization goes here.
  <%="  "* @indet %>  # i.e. start timers, HTTP requests, and low level jquery operations etc.
  <%="  "* @indet %>end

  <%="  "* @indet %>before_update do
  <%="  "* @indet %>  # called whenever a component will be re-rerendered
  <%="  "* @indet %>end

  <%="  "* @indet %>before_unmount do
  <%="  "* @indet %>  # cleanup any thing (i.e. timers) before component is destroyed
  <%="  "* @indet %>end

  <%="  "* @indet %>def render
  <%="  "* @indet %>  div do
  <%="  "* @indet %>    "<%= (@modules+[@file_name]).join('::') %>"
  <%="  "* @indet %>  end
  <%="  "* @indet %>end
<%="  "* @indet %>end
  <%- @modules.each do %><%- @indet -= 1 %><%="  "* @indet %>end
  <%- end %>end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
hyper-rails-0.4.1 lib/generators/hyperloop/templates/component_template.rb
hyper-rails-0.4.0 lib/generators/hyperloop/templates/component_template.rb
hyper-rails-0.3.0 lib/generators/hyperloop/templates/component_template.rb
reactrb-rails-generator-0.2.0 lib/generators/reactrb/templates/component_template.rb
reactive_rails_generator-0.2.0 lib/generators/reactrb/templates/component_template.rb
reactive_rails_generator-0.1.5 lib/generators/reactrb/templates/component_template.rb
reactive_rails_generator-0.1.4 lib/generators/reactrb/templates/component_template.rb