Is there any restriction on iterating arrays in Jade / Express?

I am trying to iterate over an array nest in Jade. I seem to have reached the limit.

div().slidePreview ul each slide in slides div each section in slide li each image in section img(class= image.orientation, src='http://stevepainter.s3.amazonaws.com/images/thumbs/' + image.filename) 

Another iteration also works fine (that is, each section in slides [0]). If I console.log (image), I get the full object. If I console.log (image.orientation), I get the orientation, but in the browser I get: -

 18| each image in section 19| -console.log(image.orientation) 20| img(class= image.orientation, src='http://stevepainter.s3.amazonaws.com/images/thumbs/' + image.filename) 21| Cannot read property 'orientation' of undefined> 18| each image in section 19| -console.log(image.orientation) 20| img(class= image.orientation, src='http://xxxxxxxxxxxxx.s3.amazonaws.com/images/thumbs/' + image.filename) 21| Cannot read property 'orientation' of undefined> 

Please help, this is killing me !!!!

+4
source share
1 answer

Got it. The array included the undefined element (although I first ran it through array.filter to stop this). I just added! (Image === "|| typeof image ==" undefined "|| image === null) into the if statement in the jade file and it worked.

Thanks for the comments.

0
source

Source: https://habr.com/ru/post/1434350/


All Articles