This is the code which works fine in a jekyll-template:
{% if link.url contains 'http' %}
{% assign domain = '' %}
{% else %}
{% assign domain = site.url %}
{% endif %}
Is there a way to make this a one-liner in liquid something like this:
{% if link.url contains 'http' assign domain = '' else assign domain = site.url endif %}
Or do I always have to use {% %}
to separate the commands? This looks so ugly.
{% if link.url contains 'http' %}{% assign domain = '' %}{% else %}{% assign domain = site.url %}{% endif %}
If you need the output to render on one line (or fewer), in order to reduce white space, then you can use tags like {%- if something -%}
: the additional hyphens remove all leading and trailing space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With