Sha256: f1433cc404ebb297140b61d2bf438d356e43e3d581afdd2e36d8b21745541d1a
Contents?: true
Size: 1.51 KB
Versions: 30
Compression:
Stored size: 1.51 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)? createElement: (klass, props, children)-> if React.createElement? React.createElement(klass, props, children) else <klass {...props}> { children } </klass> ### 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() @constructor.createElement(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
30 entries across 30 versions & 1 rubygems