hapi.js plugin for replying with Virtual DOM.
npm install --save hapi-vtree
Register the plugin:
var Hapi = require('hapi');
var hapiVtree = require('hapi-vtree');
var server = new Hapi.Server();
server.register(hapiVtree, function(err) {
if (err) {
console.log("Failed to load hapi-vtree.");
}
});
Reply with a virtual tree in your handler:
var h = require('virtual-dom/h');
server.route({
method: 'GET',
path: '/',
handler: function(request, reply) {
var vtree = h('div', 'Hello world!');
reply.vtree(vtree);
}
});
MIT © Zoltan Kochan