1

I want to use dotjs to replace Jade for Express

I changed

app.set('view engine', 'jade');

to

app.set('view engine', 'html');    
app.engine('html', dot.compile);

but it isn't loading for a long time and I'm not getting a response;

what's wrong with it ?

Lorenz Lo Sauer
  • 23,698
  • 16
  • 85
  • 87
anubiskong
  • 1,733
  • 1
  • 13
  • 6

1 Answers1

2

A simple way is to use express-dot:

npm install express-dot

and in your app.js:

var doT = require('express-dot');
// (optional) set globals any thing you want to be exposed by this in {{= }} and in def {{# }}
doT.setGlobals({ ... });
app.set('view engine', 'dot' );
app.engine('dot', doT.__express );

Of cause, it is suggested that compose your own as generalhenry said.
Becase if you do that , you will understand express and dot better.
express-dot do not support pre-compile, so I have a simple pre-compile example in my Github repo.
Good luck.

albertshaw
  • 96
  • 8