List of maps in Sightly
Could someone please help me with using a list of maps in Sightly.
I am using a sling model with a List<Map<String, String>> variable and wish to iterate through the list and dynamically pull values from the map based on variable names. For example a map may contain two variables with the following keys: path and title. A list would then comprise one or more of these maps.
I so far have the following HTL code:
<div data-sly-use.articlesearch="xx.xx.xx.xx.core.model.ArticleSearch">
<div data-sly-list="${articlesearch.ListOfMaps}">
<div data-sly-list.map="${item}">
${map}
${mapList.index}
</div>
</div>
</div>
This prints out the following:
path 0 title 1
path 0 title 1
...
If I try to access one of the values by its key, e.g. ${map[path]}, I get the following error:
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Invalid property name
Does anyone have any examples of how to implement this or have some guidance on how I could approach it?