Sha256: 2842cee0854ff480d32b078074d03623c5e87937628a687b1bc26953999559ca

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

Rev.registerComponent 'Main',

  ### CLASS METHODS ###

  statics:

    pathToComponentClassName: (path) ->
      "#{path}".split('/').map(_.str.classify).join('.')

    pathToComponentClass: (path) ->
      parts = @pathToComponentClassName(path).split('.')
      klass = Rev.App.Components
      for key in parts
        klass = klass[key]
        return null unless klass?
      klass

    hasView: (path) ->
      @pathToComponentClass(path)?

  ### INSTANCE METHODS ###

  getChildComponentClassName: ->
    @constructor.pathToComponentClassName @props.path

  getChildComponentClass: ->
    @constructor.pathToComponentClass @props.path

  # Some things are just easier when semi-global.
  # (Think CSRF token.)
  componentWillMount: ->
    App.props = @props.options
  componentWillUpdate: (nextProps, nextState) ->
    App.props = nextProps.options

  render: ->
    if klass = @getChildComponentClass()
      # If this version of create supports createElement that is the preferred
      # way of dynamically instantiating a component. Otherwise, fall back to
      # the old JSX transform
      if React.createElement?
        React.createElement(klass, @props.options)
      else
        <klass {...@props.options} />
    else
      <div>{"Couldn't locate component `#{@getChildComponentClassName()}`"}</div>

###
  Application code can overwrite this to do whatever extra stuff you want.
###
Rev.appComponent 'Main',
  render: ->
    console.warn "Revelry application does not define a `Main` component. Falling back to default implementation."
    <Rev.Components.Main {...@props} />

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
revelry_core-0.1.6.8 app/assets/javascripts/revelry/Main.js.cjsx
revelry_core-0.1.6.7 app/assets/javascripts/revelry/Main.js.cjsx
revelry_core-0.1.6.6 app/assets/javascripts/revelry/Main.js.cjsx
revelry_core-0.1.6.5 app/assets/javascripts/revelry/Main.js.cjsx
revelry_core-0.1.6.4 app/assets/javascripts/revelry/Main.js.cjsx