Sha256: 769920a8717fe28d1f784029f4b2ca1db2021d8ec891376829b9f3130ebbb35b

Contents?: true

Size: 1.9 KB

Versions: 2

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 %> < Hyperloop::Component

  <%="  "* @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_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

2 entries across 2 versions & 1 rubygems

Version Path
hyperloop-0.5.1 lib/generators/hyper/templates/component_template.rb
hyperloop-0.5.0 lib/generators/hyper/templates/component_template.rb