3

I am looking for a templating engine with these specific requirements in mind:

Must have:

  • logic support (if/else/etc)
  • inclusions of files / inheritance (i.e. child/master templates)
  • not HAML

Desirable:

  • rich tags/filters (a-la Django)
  • custom tags/filters
Art
  • 23,747
  • 29
  • 89
  • 101
  • 1
    Why not do templating on the client side and simply return json to the client? Saves quite some bandwidth and if you load the JS templates via an ajax call instead of hacks like putting them in ` – ThiefMaster Nov 02 '10 at 01:09
  • You can look at that question, you will probably find your answer in it : http://stackoverflow.com/questions/1787716/is-there-a-template-engine-for-node-js – HoLyVieR Nov 02 '10 at 03:14

2 Answers2

2

Jade is looking like it will become the 'standard' templating language/engine for Node. It is sort of like HAML, except it's totally not HAML. It's way better.

It doesn't have master/child templates, but I've mentioned it to TJ (the author) and I will probably push for it. For now you just need to work bottom-up when rendering templates (ie. applying child templates to parent templates through variables), which I don't see as much of a problem in most cases.

EDIT: Jade does support inheritance now: https://github.com/visionmedia/jade#a11

Prestaul
  • 83,552
  • 10
  • 84
  • 84
Tor Valamo
  • 33,261
  • 11
  • 73
  • 81
  • 3
    Could you clarify what do you mean by 'standard'? Widest adoption? Eternal blessing by Ryan Dahl himself? – Art Nov 05 '10 at 22:47
  • looks awful, I can't believe how many half-finished template engines there are out there for NodeJS that don't even come close to what you get when using Django or Rails –  Jan 20 '14 at 04:30
1

Looks like simonw's djangode is what I need:

Here's how you load it:

loader.load_and_render('template.html', context, function (error, result) {
    if (error) {
        dj.default_show_500(req, res, error);
    } else {
        dj.respond(res, result, 'text/plain');
    }
});

And template syntax seems to be complete port of Django 1.1 templates

Art
  • 23,747
  • 29
  • 89
  • 101