2

I get this weird error when I add a route '/client' in Railway.js:

500 ReferenceError: jade is not defined

I get this for any valid route in my app, not only '/client'. This line seems to be added to the top of my Jade compiled templates, and is what causes the exception:

var attrs = jade.attrs, escape = jade.escape, rethrow = jade.rethrow;

It is not present in the compiled templates unless I define a route do '/client'.

'/client/:id?', '/clients', everything else works, only '/client'.

Anyone has a clue?

emilecantin
  • 286
  • 3
  • 9
  • Which version of jade/express/railway are you using? What if switch to express ~2.x? – Anatoliy May 16 '12 at 13:36
  • @Anatoliy even today i have this bug - express 3.1 – vittore Mar 29 '13 at 20:05
  • @vittore are you able to reproduce in compound? if so, don't hesistate to open issue (https://github.com/1602/compound/issues/new) with all information we need to reproduce issue from scratch. – Anatoliy Mar 31 '13 at 20:51
  • @Anatoliy I belive it is Jade bug, as I'm not using compound.js , I'm using express.js with jade – vittore Apr 01 '13 at 00:28
  • @Anatoliy and I even found this open issue https://github.com/visionmedia/jade/issues/914 – vittore Apr 01 '13 at 00:29

1 Answers1

4

I had this exact same error when I was working on an ExpressJS app using jade templates. I figured out it was only happening on pages where I passed a local variable named client. E.g.

res.render('admin/project_new', {
  title: 'Edit Project',
  message: req.flash(),
  client: someClient
});

I think client is a reserved word when rendering jade files (or maybe something else, I'm still kinda new to Node.js). I was able to fix it by changing it to this:

res.render('admin/project_new', {
  title: 'Edit Project',
  message: req.flash(),
  theClient: someClient
});
jangosteve
  • 1,562
  • 2
  • 14
  • 26