freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <>
Subject Listing hashes (maps) in 2.3.25
Date Mon, 30 May 2016 22:21:40 GMT
FYI, I have added (to the 2.3-gae branch) a new feature for the above,
as it was very often missed. Please tell your opinion, and also, try
to break this new feature!

Here's an example:

    <#assign m = { "a": 1, "b": 2 }>
    <#list m as k, v>
      ${k} = ${v}
    <#list m>
        <#items as k, v>
          <li>${k} = ${v}

which will print:

    a = 1
    b = 2

        <li>a = 1
        <li>b = 2

Loop variable built-ins like ?index, ?itemParity, etc. work both on k
and v, just as they worked on sequence items.

There's new optional interface that helps to implement this more
correctly and efficiently, TemplateHashModelEx2, which extends
TemplateHashModelEx; see in the JavaDoc of it.

 Daniel Dekany

View raw message