senzacionale
senzacionale

Reputation: 20936

free marker template how to use for statement in double HashMap

In free marker template i want to print HashMap in HashMap. Is this possible?

I try with

<#list capitalList?keys as key>
    ${key} = ${capitalList[key]}
</#list> 

but this not printing HashMapin HashMap. How can i do this with free marker template. Exist foreach or for?

Upvotes: 1

Views: 274

Answers (1)

longhua
longhua

Reputation: 4262

You can use nest list directive. A simple example:

<ul>
<#list hm2d?keys as hm2d_key>
    <#assign hm = hm2d[hm2d_key]>
    <li>${hm2d_key}:
        <ul>
        <#list hm?keys as key>
            <li>${key} = ${hm[key]}</li>
        </#list>
        </ul>
    </li>
</#list>
</ul>

Upvotes: 1

Related Questions