Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dust.js - render the first element of an array

I have a .json data object that looks like this:

{ images: [ { photo: image.jpg } {something : else} ] }

I want to get access in my dust templating to the image.jpg item. Is there a straightforward way to select only the first dictionary in that array without looping through? I'd prefer to avoid a loop in my template because it will render a section that is expecting style="background-image: url({photo});" multiple times.

like image 447
fox Avatar asked Feb 13 '23 03:02

fox


1 Answers

Use {images[0]} to get just the first element.

like image 186
rragan Avatar answered Feb 15 '23 17:02

rragan