How we read the list<map;string>

Yadid Qin <[email protected]> Wed, 28 May 2014 07:57:42 +0000
Newsgroups gmane.comp.web.freemarker.user,gmane.comp.web.freemarker.devel
Message-ID <11E7A96539DB6844B314AAAF65F01065076401F6@ONWATER53M.ad.onsemi.com>
Hello Freemarker Team,

There is one issue it confused me.

Eg: java code:

SimpleHash root = new SimpleHash();
List<Object> list = new ArrayList<Object>();
     list.add("red");
     list.add("green");
     list.add("blue");
     SimpleHash mapColor = new SimpleHash();
     mapColor.put("c1", "red");
     mapColor.put("c2", "green");
     mapColor.put("c3", "blue");
     list.add(mapColor);
root.put("theList", list);

FTL file:
<#list theList as item>

<#if item_index =3>    --> if I do not know the index=3, then how I read the map in the list.
<#assign keys = item?keys>
<#list keys as key>
${key} = ${item[key]}<br>
</#list>
<#else>
${item_index + 1}.  ${item}<br>
</#if>

</#list>

Output:
+- theList
| |
+- 1. red
| |
+- 2. green
| |
+- 3. blue
| |
||
+- c1 = red
||
+- c2 = green
||
+- c3 = blue


Thanks & Best Regards,
Yadid

------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user