How do you iterate over a list map with a StringTemplate?

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

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

Ive tried the card, i.e. Map<String,List<String>> , but I can’t figure out how you will iterate over it, i.e. this does not work:

 <ul class="chevron"> $x:{y| <li>$y$</li><ul class="chevron"> $y:{z|<li>$z.name$/li>}$ </ul> }$ </ul> 
+4
source share
1 answer

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

 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 notation $x.(k)$ .

+3
source

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


All Articles