Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{# Bad: Messy and Hard to Follow #}
{% if link %}
<a href="/recipes/cookies">
{% endif %}
<span>Cookies</span>
{% if link %}
</a>
{% endif %}
{# Good: Clean & Clear #}
{% set content %}
<span>Cookies</span>
{% endset %}
{% if link %}
<a href="/recipes/cookies">
{{ content }}
</a>
{% else %}
{{ content }}
{% endif %}
@clarknelson

This comment has been minimized.

Copy link

clarknelson commented Dec 5, 2019

beautiful thanks, i've tried to solve this with a ternary before but this is much better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.