I'm having trouble displaying an array of images in jade, they are being passed from javascript ok, but I'm just getting a blank box with just the heading. This is the section from jade causing me trouble.
h2 Connections
ul
script(type='text/javascript')
- for (i = 0; i < 5; i++)
li
- for (j = (i*5); j < j+1; j++)
- for (k = j; k < (j+5); k++)
img(src='#{connections[k]}', width='50', height='50')
ul
The latest problem I'm having is that k in img(src='#{connections[k]}', width='50', height='50')is undefined! I've tried moving it, but as said below, I realise [k] needs to be in the #{} section.
use each connection in connection.
For your problem, you're using #{} to interp for no reason. Use img(src=connections[k],...)
If you want to loop through every images you have, you need to use something like this:
img(src='#{connections[k]}', width='50', height='50')
Everything inside your #{} will be executed as JavaScript. You can do any operation and use any module, as long as you define them as local.
In Express.js, if you want to use (for example) Moment.js in your Jade template:
app.locals.moment = moment;