Reports - Freemarker template question - hide data if set is empty

I am trying to build a freemarker template and I want to hide some data if the result set of the sub-entities is null (tabulated area)

So e.g. in the generated template if I add the following after <#if Lines2?has_content>

<#if Lines2?has_content>
<p>Lines has content</p>

If the “Lines2” list size is 0 (no invoice lines) I do not want to be able to see

Lines has content

But it always shows even if there are no invoice lines… e.g. (showing no lines for the invoice)

picture example

<?xml version="1.0" encoding="utf-8"?>

    ...

    <#assign Invoice1 = Root.bands.Invoice1><br/>
    <#assign Lines2 = Root.bands.Lines2><br/>

    ...

    <table class="report-table" border="1" cellspacing="0" >
    <thead>
    <tr>
    <th>Lines.Line type</th>
    <th>Lines.Quantity</th>
    <th>Lines.Rate</th>
    <th>Lines.Sub total</th>
    </tr>
    </thead>
    <tbody>
    <#if Lines2?has_content>

    **<p>Lines has content</p>**

    <#list Lines2 as row>
    <tr>
    <td> ${(row.fields('lineType'))!?string!} </td>
    <td> ${(row.fields('quantity'))!?string!} </td>
    <td> ${(row.fields('rate'))!?string!} </td>
    <td> ${(row.fields('subTotal'))!?string!} </td>
    </tr>
    </#list>
    </#if>
    </tbody>
    </table>

@daryn

I’m having the same problem. Did you ever find a resolution?

No I didn’t,
I ended up switching to JasperReports