35

I have started working with NodeJs. First, I was just using it for providing simple REST api which has access to NOSQL databases. Now I also want to build html pages and use NodeJS to serve static files, as well as dynamic content using ExpressJs. Jade seems to be the templating library on ExpressJs so planning to use it. Are there any good resources so that I can learn jade. Also is it easy to write some big html pages using jade? I'd prefer some thing like php script tags etc embeded in html files as it is more convenient.

Please let me know what you think about it and any alternatives I should look into.

Thanks

Bakudan
  • 19,134
  • 9
  • 53
  • 73
Lalith
  • 19,396
  • 17
  • 44
  • 54

4 Answers4

22

There is also a great resource called Jade Template Syntax by example.

ace
  • 7,293
  • 3
  • 23
  • 28
Francisco
  • 221
  • 2
  • 2
  • thanks for sharing, its indeed very useful and the best part is you get to see the html too :) – Bharat Mar 01 '15 at 08:43
19

There's a very complete tutorial here: http://dailyjs.com/2010/11/01/node-tutorial/.

These posts are well written, step by step and with full source code available. I recommend.

Marcos Oliveira
  • 1,697
  • 1
  • 14
  • 13
17

Jade is the default template engine, but it's not your only option see: http://expressjs.com/guide/using-template-engines.html

It sounds like you want a template engine that's more like <h1><% variable %></h1> you should try EJS

http://mustache.github.com/ and https://github.com/jquery/jquery-tmpl are also well supported in node.

Also of note is weld which using 100% valid html for it's templates http://blog.nodejitsu.com/micro-templates-are-dead

Personally I like Jade in combination with Stylus (same minimal markup applied to css)

generalhenry
  • 17,227
  • 4
  • 48
  • 63
1

To send static files easily, just use: res.sendfile('index.html');

guiomie
  • 4,988
  • 6
  • 37
  • 67