Controlling whitespace
In the previous sections, we learned how to use conditionals with variable data types to ensure that we always receive a correct value. However, even with our conditionals, the same values can be accompanied by some unwanted whitespaces:
Collection info: {% if collection %} The collection's name is {{ collection.title }} ! {% endif %}
In the previous example, we have created a conditional that will return true
if our collection object exists, ensuring that our message will not be incomplete. While our result looks correct, if we were to inspect the page, we would see that things aren't perfect:
Collection info: The collection's name is Winter Shoes !
As we can see from our previous example, we have successfully recovered the collection information. However, we can see a significant number of empty spaces around our message, which results from processing Liquid code. Even though not every Liquid code will output...