Can I bind / bind labels to liquids as a one-liner? Is there a separator character?

This is the code that works fine in jekyll template:

{% if link.url contains 'http' %}
   {% assign domain = '' %}
{% else %}
   {% assign domain = site.url %}
{% endif %}

      

Is there a way to do it in one layer in a liquid something like this:

{% if link.url contains 'http' assign domain = '' else assign domain = site.url endif %}

      

Or do I always need to use {% %}

to separate commands? It looks so ugly.

{% if link.url contains 'http' %}{% assign domain = '' %}{% else %}{% assign domain = site.url %}{% endif %}

      

+3


source to share


1 answer


If you need the output to render on one line (or less) to reduce the white space, you can use tags like {%- if something -%}

: extra hyphens remove all leading and trailing space.



+1


source







All Articles