Created
April 1, 2016 17:37
-
-
Save grebaldi/63ce808c4e312f5de04f144fb47bc646 to your computer and use it in GitHub Desktop.
Stupid rendering approach
This file contains 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
const graph = { | |
page: Page({ | |
headline: Headline({ | |
text: context => 'Hello World!' | |
}), | |
body: Collection({ | |
collection: context => context.get('posts'), | |
itemName: context => 'post', | |
itemRenderer: BlogPost({ | |
headline: context => context.get('post').get('title'), | |
creationDate: context => context.get('post').get('creationDate'), | |
text: context => context.get('post').get('text') | |
}) | |
//itemRenderer: context => context.get('post').get('title') | |
}) | |
}) | |
}; | |
const Result = Runtime.process(graph); | |
React.render( | |
<Result /> | |
); | |
const Collection = component(context => children => { | |
const itemName = children.get('itemName'); | |
const collection = children.get('collection'); | |
const itemRenderer = children.get('itemRenderer'); | |
return collection.map(item => { | |
return itemRenderer(context.set(itemName))(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment