Question

How to keep the background without serving text for conditional liquid formatting?

  • 30 March 2018
  • 1 reply
  • 213 views

Hi, I find that this HTML snippet works:



 {% if value == 0 %}

<div style="color: darkred; background-color: #C6EFCE; text-align:center">

<div style="color: #006100;">10 </div </div>

{% elsif value == 1 %}

<div style="color: darkred; background-color: #FFC7CE; text-align:center">

<div style="color: #9C0006;">-10 </div </div>

{% endif %}



But this does not -



              {% if value == 0 %}

<div style="color: darkred; background-color: #C6EFCE; text-align:center">

<div style="color: #006100;"></div </div>

{% elsif value == 1 %}

<div style="color: darkred; background-color: #FFC7CE; text-align:center">

<div style="color: #9C0006;">-10 </div </div>

{% endif %}



That second snippet won’t show any formatting for cells where value == 0.



How do I keep the background formatting, but have the cell be blank for text? Thanks.


1 reply

Userlevel 2

Hi @sebastian ,



If we add padding to the div style, we should be able to render the formatting without needing to have text, like so:



    {% if value == 0 %}

<div style="color: darkred; background-color: #C6EFCE; text-align:center">

<div style="color: #006100; padding:10px;"></div </div>

{% elsif value == 1 %}

<div style="color: darkred; background-color: #FFC7CE; text-align:center">

<div style="color: #9C0006; padding:10px;"> </div </div>

{% endif %}

Reply