Dust.js - visualize 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 access dust texturing on an element image.jpg. Is there an easy way to select only the first dictionary in this array without scrolling? I would prefer to avoid the loop in my template because it will display a section that expects style="background-image: url({photo});"several times.

+4
source share
1 answer

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

+8
source

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


All Articles