Created
November 7, 2019 21:42
-
-
Save jakedohm/39190ec533e69e83b9cee4bdf3898a60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# 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 %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
beautiful thanks, i've tried to solve this with a ternary before but this is much better