Skip to content

0.2.7 elements Module

Ivan S Glazunov edited this page Feb 20, 2015 · 2 revisions

Module

[new] () => Module extension;

Wraps any other type of data in the module.

Returns the successor of that same type.

Instance

String
var m = Module('string');
m().render(function(result) {
	console.log(result); // 'string'
});
context
var m = Module('<%= data %>');
m().render(function(result) {
	console.log(result); // 'content'
}, { data: 'content' });
div
var m = Module(div()());
m().render(function(result) {
	console.log(result); // <div></div>
});
Mixin
var m = Module(mixin(function(a) {
	return div()(a);
}));
m('data').render(function(result) {
	console.log(result); // '<div>data</div>'
});

Clone this wiki locally