<table class="wide text-center">

    <tr valign="top">
        <td><b>{$Columns[0]->GetCaption()}</b></td>
        <td><b>{$Columns[2]->GetCaption()}</b></td>
        <td><b>{$Columns[3]->GetCaption()}</b></td>
        <td><b>Score</b></td>
        <td><b>Final gap</b></td>
    </tr>

    {foreach item=Row from=$Rows name=RowsGrid}
        <tr valign="top">
            <td>{$Row[0]}</td>
            <td>{$Row[2]}</td>
            <td>{$Row[3]}</td>
            {if $Row[1]-$Row[4] > 0}
                <td><b>{$Row[1]}</b>:{$Row[4]}</td>
            {else}
                <td>{$Row[1]}:<b>{$Row[4]}</b></td>
            {/if}
            <td
                    {if $Row[1]-$Row[4] > 0}
                        style="color:green;"
                    {else}
                        style="color:red;"
                    {/if}
                    ><b>{$Row[1]-$Row[4]}</b>
            </td>
        </tr>

    {/foreach}

    {if $Grid->HasTotals()}
        <tr>
            {foreach item=Total from=$Totals}
                {strip}
                    <td>
                        {if not $Total.IsEmpty}
                            {if $Total.CustomValue}
                                {$Total.UserHTML}
                            {else}
                                {$Total.Aggregate} = {$Total.Value}
                            {/if}
                        {/if}
                    </td>
                {/strip}
            {/foreach}
        </tr>
    {/if}

</table>

<p>
    The &quot;Final gap&quot; column and this note are added in the custom template.
</p>