Reputation: 21
So I have some experience with Pebble template syntax, however I'm having an issue trying to retrieve an entry from a Map by the key, and because the Pebble documentation isn't very intuitive, I've been spinning my wheels trying to figure out the proper syntax. Basically, here's my overall logic:
{% set segmentsLength = file.value['segments']|length %}
{% for sg in range(1, segmentsLength) %}
{% set segment = file.value['segments'].value[sg] %}
<Segment type="{{ segment.value['segmentType'] }}">
<Start>{{ segment.value['start'] }}</Start>
<End>{{ segment.value['end'] }}</End>
</Segment>
{% endfor %}
However, segment is not returning the map of Segments, so Start and End are just empty. I've been able to get the values set by just having a separate loop as below, but than the xml elements won't be ordered as I need them:
{% for segment in file.value['segments'] %}
<Segment type="{{ segment.value['segmentType'] }}">
<Start>{{ segment.value['start'] }}</Start>
<End>{{ segment.value['end'] }}<End>
</Segment>
{% endfor %}
Any advice is appreciated. Thanks!
Upvotes: 2
Views: 590