Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Templating Engine for Node that's NOT Jade

Jade is indeed very neat, but I personally dislike the syntax and look of it. Yeah, being able to write just :

body
  h1 Hello
  p This is 
    b bold

Thats cool and all, but I prefer the look and feel of HTML/XML still. It was made to be human and machine readable and overall I think it's easier to glance at and understand.

Are there any templating engines that work more like:

<body>
  <h1>{title}</h1>
  <p>{content}</p>
</body>

Using the same Jade like concept of:

res.render('index', {
  title:pageTitle,
  content:pageContent
});
like image 392
Oscar Godson Avatar asked Sep 11 '11 01:09

Oscar Godson


3 Answers

Take a look at EJS. Allows you to use regular HTML and embed Javascript code.

For example:

<div>
<% if (foo) { %>
foo
<% }else { %>
bar
<% } %>
</div>

Also, what you're looking for is an "Express-compatible" templating engine, and EJS is Express-compatible. It's made by one of the main guys behind Express.

like image 70
JSPP Avatar answered Sep 18 '22 10:09

JSPP


You can use straight HTML in Jade, give this a try:

<body>
  <h1>#{title}</h1>
  <p>#{content}</p>
</body>
like image 21
Jack Avatar answered Sep 21 '22 10:09

Jack


Something that specifically looks like that would probably be Mustache for Node.js. Check the demo.

like image 20
Jorge Israel Peña Avatar answered Sep 20 '22 10:09

Jorge Israel Peña