| <html> |
| <head> |
| <title>FreeMarker: List Iterator Test</title> |
| </head> |
| <body> |
| <#assign list= ["one", "two", "three", "four", "five"]> |
| <#assign hash = {"key", list}> |
| <#assign hash2 = {"value", hash}> |
| |
| <p>A simple test follows:</p> |
| |
| <p>${message}</p> |
| |
| <p>Now iterate over a list:</p> |
| |
| <#foreach item in list> |
| <p>${item}</p> |
| </#foreach> |
| |
| <p>Now iterate again:</p> |
| |
| <#list list as item> |
| <p>${item_index}. ${item}</p> |
| </#list> |
| |
| <p>Iterate over a list in a hash:</p> |
| |
| <#list hash.key as item> |
| <p>${item}</p> |
| </#list> |
| |
| <#foreach item in hash.key> |
| <p>${item}</p> |
| </#foreach> |
| |
| <#foreach item in hash[ "key" ]> |
| <p>${item}</p> |
| </#foreach> |
| |
| <#list hash["key"] as item> |
| <p>${item}</p> |
| </#list> |
| |
| <p>Now test the list and foreach keywords...</p> |
| |
| <#list hash2["value"].key as key> |
| <p>${key}</p> |
| </#list> |
| |
| <#foreach az in hash2.value.key> |
| <p>${az}</p> |
| </#foreach> |
| |
| </body> |
| </html> |