add widgetsFor helper

This allows individual widgets to be accessed
from preview templates that handle lists
This commit is contained in:
Shawn Erquhart
2017-03-06 12:27:41 -05:00
parent 73d5cf9031
commit 9dca9f912a
2 changed files with 41 additions and 0 deletions

View File

@ -110,8 +110,24 @@
}
});
var AuthorsPreview = createClass({
render: function() {
return h('div', {},
h('h1', {}, 'Authors'),
this.props.widgetsFor('authors').map(function(author, index) {
return h('div', {key: index},
h('hr', {}),
h('strong', {}, author.getIn(['data', 'name'])),
author.getIn(['widgets', 'description'])
);
})
);
}
});
CMS.registerPreviewTemplate("posts", PostPreview);
CMS.registerPreviewTemplate("general", GeneralPreview);
CMS.registerPreviewTemplate("authors", AuthorsPreview);
CMS.registerPreviewStyle("/example.css");
CMS.registerEditorComponent({
id: "youtube",