Re: How we read the list<map;string>
[email protected] Thu, 29 May 2014 06:56:06 +0000
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Yadid, You can use is_hash_ex to find if the item is a map http://freemarker.org/docs/ref_builtins_expert.html#ref_builtin_isType ---------- From: "Yadid Qin" <[email protected]> To: "[email protected]" <[email protected]> CC: "[email protected]" <[email protected]> Sent: 28 May 2014 20:28 Subject: [FreeMarker-user] How we read the list 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