Search code examples
stringtemplate

How to use partial templates with map in StringTemplate?


I've got a map of city names => distance-from-origin.

I'd like to use a partial with this map, and create something like so:

<ul>
<li>city1: distance1</li>
<li>city2: distance2</li>
<li>city3: distance3</li>
</ul>

What is the canonical way to do this with StringTemplate?

Thanks.


Solution

  • <ul>
    $amap.keys:{k | <li>$k$: $amap.(k)$</li>}$
    </ul>