Robeezy
Robeezy

Reputation: 2464

Express JS not rendering jade template

I'm going to keep this short, I'm just trying to render a jade template using express js. I'm using express 3.0.0rc5 and jade 0.27.6.

Here's my jade templates, the layout:

// test-layout.jade
doctype 5
html
  head
    title My title
    block head
  body
    #content
      block content

And the index:

// test-index.jade
extends test-layout

block head
  script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js")

block content
  h1 My page

Here's some excerpts from app.js:

var app = express();
// Configuration
app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.get('/test-jade', function(req, res) {
    res.render('test-index', {}, function(err, html) {
    });
  });
app.get('/test', function(req, res) {
  res.send('this works');
});

Now whenever I try to go to http://myurl.com/test-jade the browser just hangs and timesout without showing any output in the console (even though I'm in dev mode).

However when I go to http://myurl.com/test I see 'this works'.

I feel like I'm missing something really simple here, I'm currently upgrading from 2.5 to 3.0.

Thanks in advance if anyone has advice.

Upvotes: 2

Views: 5368

Answers (1)

Robert Peters
Robert Peters

Reputation: 4104

Is it the blank call back?

 res.render('test-index', {}, function(err, html) {
 });

In my app I'm using

res.render('test-index', {});

Upvotes: 4

Related Questions