require("babel/polyfill");
import {Module} from '../Module.js';
require("babel/polyfill");
import {Module} from '../Module.js';
depends: Kronicle.Module The module used for rendering main views. An array of smaller components are usually used to make up a view. The constructor takes an args object that has the following two properties:
export class View extends Module {
constructor (args){
this.template = args.template || () => { return ""};
this.components = []
if(args.components){
this.addComponents(args.components);
}
super({name: args.name + 'View'});
}
The render method passes any data avaialbe to a template and returns the rendered string Takes two arguments
render(err, data) {
if(!err) {
return this.template(data);
}
}
The method used to add an array of Kronicle Components to the View Takes one argument:
addComponents (components) {
for(let component of components){
this.addComponent(component);
}
}
The method used to add a single Kronicle Component to the View Takes one argument:
addComponent (component){
this.components[component.name.split('Component')[0]] = component;
}
}