Sha256: a6f62b06dc46dd52ad4cd4bfb232fba6204e78c14f51b9da477f15936a52f588
Contents?: true
Size: 1.54 KB
Versions: 11
Compression:
Stored size: 1.54 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 componentWillUpdate: (nextProps, nextState) -> App.props = nextProps 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
11 entries across 11 versions & 1 rubygems