Using Swig Templates with Hapi.js #nodejs #javascript @hapijs

Oscar Brito



While migrating a node.js application from Express to Hapi.js I found the need to use Swig as template engine instead of handlebars.

I prefer Swig because it have hierarchy blocks (aka extends) that work way better than the handlebars partials.

Simply, to make it work you just have to:


Hapi.createServer(
'localhost',
8080,
{

views: {
path: "./views/",
engines: {
html: "swig"
}
}

}).start();


Be sure that you have included the the Swig dependency on package.json.

At last, be sure you check Hapi.js if you are thinking on a Server Framework for node.js ...


Links:

http://spumko.github.io/





Visit www.divhide.com for more informations, contacts and news about Web Development.
See other blog posts at blog.divhide.com.



Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.


Feel free to contact divhide.