this works fine:
<#list myObjects as myObject>
<tr>
<td>${myObject.person.surname}</td>
<td>${myObject.myListOfCountries[0].city.name}</td>
</tr>
</#list>
However if I instead try to create a nested list like so, which does not work :
<#list myObjects as myObject>
<tr>
<td>${myObject.person.surname}</td>
<#list myObject.myListOfCountries as item>
<td>${item.city.name</td>
</#list>
</tr>
</#list>
the error I receive is shown below :
freemarker.core.ParseException: Encountered "/"
Any ideas what causes the error - are nested lists allowed in freemarker ?
FreeMarker doesn't support modifying collections. But if you really want to do this in FreeMarker (as opposed to in Java), you can use sequence concatenation: <#assign myList = myList + [newItem]> . Here you create a new sequence that wraps the two other sequences.
The has_content FunctionFreeMarker has built-in functions to detect for variables. The most common method of detecting for empty or null values uses the has_content function and the trim function. The has_content function is often used with another built-in FreeMarker function to detect for null values.
Macro variable stores a template fragment (called macro definition body) that can be used as user-defined directive. The variable also stores the name of allowed parameters to the user-defined directive.
You haven't closed your brace. It should be:
<td>${item.city.name}</td>
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