I have a an if
condition in my liquid template like this
Username: {{user.email}}
{% if extras['password_to_be_sent'] %}
Password: {{extras['password_to_be_sent']}}
{% endif %}
Trial expiration: {{user.trial_expiration}}
However this is generating a line break when the if condition does not evaluate to true
so the above generated output like this
Username: Abc
Trail Expiration: 2019-11-10
I want to remove the additional line break when the if
condition does not evaluate to true
i tried adding -
as suggested here https://shopify.github.io/liquid/basics/whitespace/
so updated code to
Username: {{user.email}}
{%- if extras['password_to_be_sent'] -%}
Password: {{extras['password_to_be_sent']}}
{%- endif -%}
Trial expiration: {{user.trial_expiration}}
but this is giving an exception Liquid::SyntaxError (Liquid syntax error: Tag '{%- if extras['password_to_be_sent'] -%}' was not properly terminated with regexp: /\%\}/)
Additionally, I am saving the template code in database, if that helps.
Any help in this would be appreciated. Thanks.
Answered above in a comment, but here it is again:
I see you've also tagged Ruby on Rails — if your Rails app is consuming a version of Liquid earlier than 4.0.0, you won't be able to use the whitespace control tags. Those were added in Liquid 4.0.0.