2.3.1 • Published 8 years ago
vdom-to-html v2.3.1
vdom-to-html
Turn virtual-dom nodes into HTML
Installation
npm install --save vdom-to-html
Usage
var VNode = require('virtual-dom/vnode/vnode');
var toHTML = require('vdom-to-html');
toHTML(new VNode('input', { className: 'name', type: 'text' }));
// => '<input class="name" type="text">'
Special case for Widgets
Widgets are used to take control of the patching process, allowing the user to create stateful components, control sub-tree rendering, and hook into element removal. Documentation is available here.
Widgets are given an opportunity to provide a vdom representation through an optional render
method. If the render
method is not found an empty string will be used instead.
var Widget = function(text) {
this.text = text;
}
Widget.prototype.type = 'Widget';
// provide a vdom representation of the widget
Widget.prototype.render = function() {
return new VNode('span', null, [new VText(this.text)]);
};
// other widget prototype methods would be implemented
toHTML(new Widget('hello'));
// => '<span>hello</span>'
2.3.1
8 years ago
2.3.0
9 years ago
2.2.0
10 years ago
2.1.1
10 years ago
2.1.0
10 years ago
2.0.0
10 years ago
1.3.1
10 years ago
1.3.0
10 years ago
1.2.5
10 years ago
1.2.4
10 years ago
1.2.3
10 years ago
1.2.2
10 years ago
1.2.1
10 years ago
1.2.0
10 years ago
1.1.0
10 years ago
1.0.1
11 years ago
1.0.0
11 years ago
0.0.0
11 years ago