Whitespace and liquid conditionals in labels

(Simon Clark) #1

I’ve been setting up a field’s label/view_label/group_label using Liquid if/else and noticed that Liquid seems to preserve whitespace. This means that if I lay out the label text with newlines, the view and group labels won’t match existing ones and so they are displayed in the field picker twice.

Does anyone have a way to avoid this?

I’d much prefer to format my code like this:

view_label: "
  {% if _explore._name == 'my_explore' %}
    Some View Label
  {% else %}
    Some Other View Label
  {% endif %}"

rather than this:

view_label: "{% if _explore._name == 'my_explore' %}Some View Label{% else %}Some Other View Label{% endif %}"

(Izzy) #2

It looks like liquid supports the use of some operators to strip whitespace out:

But we need to do some tinkering to Looker to make it work with that syntax— so I wouldn’t try it right now. Seeing if it’s something that’s easy to add…

1 Like