Last active
August 29, 2015 13:56
-
-
Save joshski/9109087 to your computer and use it in GitHub Desktop.
React component in pogo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
render () = | |
div ( | |
h1 { id = 'main_heading' } (props.heading) | |
p (props.introduction) | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React = require 'react' | |
dslify = require 'dslify' | |
component = require "./react-component.pogo" | |
render js = component.render.to string() | |
transformed render = dslify.transform (render js) | |
tag (react dom method) = | |
@{ | |
args = Array.prototype.slice.call(arguments) | |
if (is not attributes (args.0)) | |
args := [null].concat (args) | |
react dom method.apply(this, args) | |
} | |
is not attributes (obj) = | |
!(obj :: Object) || (obj._lifeCycleState) | |
DSL (props) = | |
this.props = props | |
this | |
for @(key) in (React.DOM) | |
DSL.prototype.(key) = tag (React.DOM.(key)) | |
component.render () = transformed render (@new DSL (this.props)) | |
Component = React.create class (component) | |
howdy = Component { heading = "Doody", introduction = "Good day" } | |
React.renderComponentToString(howdy) @(html) | |
console.log (html) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-reactid=".r[3fjcy]" data-react-checksum="589508296"> | |
<h1 id="main_heading" data-reactid=".r[3fjcy].[0]">Doody</h1> | |
<p data-reactid=".r[3fjcy].[1]">Good day</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment