vendredi 20 février 2015

express 4 jade invalid error

I am using express 4 with jade. I have an error in the jade template like this:


file: test.jade, data.item.test is undefined:



extends layout

block content
if data.item.test
div.content-section


the html response looks like this:



TypeError: /work/web/views/layout.jade:37
35| header
36| i.arrow-up
> 37| h4.user-name #{user.firstName.charAt(0).toUpperCase() + user.firstName.slice(1)} #{user.lastName.charAt(0).toUpperCase() + user.lastName.slice(1)}
38| a(href="/profile").edit-profile
39| i
40| | Edit Profile

Cannot read property 'firstName' of undefined


if I fix the actual error in the jade template, everything will work fine and no error will be reported in the layout.


How can I fix this because it's very difficult to debug errors in jade templates


Aucun commentaire:

Enregistrer un commentaire