This is what ?chunk for ( http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_chunk ):
<#list section.field?chunk(2) as row> <#list row as field> <div class="col${field_index + 1}"> ${ field.@label }: <input type="text"/> </div> </#list> </#list>
Otherwise, I do not know what error you will get with your decision, but, of course, there is an error in that it displays all the fields except the last one twice. You can freely play with indexes with something like
<#assign fields = section.field> <#assign idx = 0> <#list 0..999999 as _> <#if idx == fields?size><#break></#if> ... even column ... <#assign idx = idx + 1> <#if idx == fields?size><#break></#if> ... odd column ... <#assign idx = idx + 1> </#list> ...
but, as you can see, this really is not suitable for FreeMarker (this is terribly verbose).
source share