Search code examples
grailsgsp

Grails, display blank if value is 0.0


I want fields that contains a numeric value of 0.0 to be displayed as blank. How can I do that in a grails view?

Heres the gsp code:

<g:each in="${od.plannedVolumes}" status="j" var="pv">
       <td id="pv_center">${pv.volume}</td>
</g:each>

pv.volume is declared in the domain as a Double.


Solution

  • Making use of groovy truth you could output a non breaking space if zeroed.

    <td id="pv_center">${pv.volume ?: '&nbsp'}</td>