Question

I need to produce HTML output that will look like this:

 - 2010
    - Item 1
    - Item 2
 - 2011
    - Item 9
 - 2012
    - item 6

Ive tried a map, ie Map<String,List<String>> but I cant work out how you would iterate over it, ie this doesnt work:

<ul class="chevron">
$x:{y|
    <li>$y$</li><ul class="chevron">
        $y:{z|<li>$z.name$/li>}$
    </ul>
}$
</ul>
Was it helpful?

Solution

In YAML notation, if the contents of the variable x (which is of type Map<String,List<String>>) are:

x:
  2010: [Item 1,Item 2]
  2011: [Item 9]
  2012: [Item 6]

The following will do what you ask for:

<ul>
$x.keys:{
k | <li>$k$</li>
  <ul>
    <li>$x.(k);separator="</li>
    <li>"$</li>
  </ul>
}$</ul>

Note the $x.(k)$ notation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top