Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a template engine for Node.js? [closed]

Check out the Node js modules wiki page. They have listed all the templating engines supporting node.js.


You should be able to use mustache.js, if it doesn't work send me the issues and I'll get it fixed because I'm about to be using them in node.js anyway.

http://github.com/janl/mustache.js

I know that it works without a DOM because a bunch of CouchDB standalone apps are using it in a Spidermonkey view server.


If you like haml, but want something even better check out http://jade-lang.com for node, I wrote haml.js as well :)


There are new templating engines all the time.

underscore.js adds a lot of functional programming support to js, and has templating.

And just today I heard about this: http://github.com/SamuraiJack/Shotenjin-Joosed


You should take a look at node-asyncEJS, which is explicitly designed to take the asynchronous nature of node.js into account. It even allows async code blocks inside of the template.

Here an example form the documentation:

<html>
  <head>
    <% ctx.hello = "World";  %>
    <title><%= "Hello " + ctx.hello %></title>
  </head>
  <body>

    <h1><%? setTimeout(function () { res.print("Async Header"); res.finish(); }, 2000)  %></h1>
    <p><%? setTimeout(function () { res.print("Body"); res.finish(); }, 1000)  %></p>

  </body>
</html>