Skip to content

Instantly share code, notes, and snippets.

@grebaldi
Created April 1, 2016 17:37
Show Gist options
  • Save grebaldi/63ce808c4e312f5de04f144fb47bc646 to your computer and use it in GitHub Desktop.
Save grebaldi/63ce808c4e312f5de04f144fb47bc646 to your computer and use it in GitHub Desktop.
Stupid rendering approach
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