I'm trying to iterate over an nest of arrays in Jade. I seem to have hit a 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)
One less iteration and it works fine (i.e. 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!!!!
Got it. The array included an undefined element (even though I ran it through array.filter first to stop that). I just added !(image === "" || typeof image == "undefined" || image === null) to an if statement on the jade file and it worked.
Thanks for the comments.