Railway.js + Jade crashes when a route to '/client' is defined

423 Views Asked by At

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?

1

There are 1 best solutions below

1
On

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
});