Skip to content

Instantly share code, notes, and snippets.

@sminutoli
Created September 13, 2016 15:16
Show Gist options
  • Save sminutoli/62c1cf6777cc02ea068440750bad209b to your computer and use it in GitHub Desktop.
Save sminutoli/62c1cf6777cc02ea068440750bad209b to your computer and use it in GitHub Desktop.
require('./Container');
require('./Renderizable');
const Category = {
name: 'Category',
className: 'category',
tagName: 'article',
toHTML: Renderizable.toHTML,
firstItem: Container.firstItem,
addItem: Container.addItem,
init: Container.init,
emptyItem: Container.emptyItem,
getItems: Container.getItems,
from(obj){
let result = EnhancedObject.from.call(this, obj).init();
obj.item && result.addItem( Item.from(obj.item) )
return result;
},
children(){
return `
<h1>${this.name} (${this.items.length})</h1>
${this.firstItem().toHTML()}
`;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment