I am new to FreeMarker and I am working on a project which uses it.
The scenario is, I have two lists in FreeMarker which I am getting from the backend(say firstNames & lastNames. Now what I want to do is, I want to loop through these lists and access the values from both lists at the same index.
I want the output to be something like
<#assign firstNames = fNames/>
<#assign lastNames = lNames/>
<body>
<table>
<loop from 0 to 5>
<tr>
<td>Hello firstNames[i] lastNames[i]</td>
</tr>
</loop>
</table>
</body>
For simplicity I will assume that the length of the lists will always be the same(say 5).
Is there a way to achieve this??
Like this:
<#list firstNames as firstName>
Hello ${firstName} ${lastNames[firstName?index]}
</#list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With