domjs-site-tree
Domjs based SiteTree
DomjsSiteTree
allows configuration of SiteTree's with domjs style templates.
Basic example:
Let's say we have follwing domjs view files:
base.js
exportstitle = "SitTree test page"; exports { ; ;} exports { ; ; ;}
homepage.js
exports_parent = ;exports { ; ;}
subpage.js
exports_parent = ;exports { ; ;}
SiteTree configuration may look as:
var DomjsSiteTree = ;var Domjs = ;var domjs = document; // Initialize SiteTree instance:var siteTree = domjs; // Retrieve view nodes:var homepageView = ;var subpageView = ; // Switch between views in document:// Present homepagesiteTree; // Switch to subpagesiteTree; // Switch back to homepagesiteTree
Installation
$ npm install domjs-site-tree
API
new DomjsSiteTree(domjs)
var DomjsSiteTree = ;var Domjs = ; var domjs = document; var siteTree = domjs;
On initialization Domjs instance needs to be provided.
Templates format
DomjsSiteTree
templates can be provided in a form of:
- functions, where content should be built using domjs element constructors (DocumentFragment will automatically be resolved via domjs)
- strings, which will be treated as plain text (not HTML) content for addressed elements.
For detailed documentation of configuration of SiteTree, please refer to SiteTree documentation
Tests
$ npm test