In Jekyll templating, the Liquid tags used can generate a lot of white spaces. From Liquid's documents, use {{-
-}}
or {{%
%}}
can strip these white spaces.
But I got a Liquid syntax error
when Jekyll building.
How to fix this problem or do you have any other methods to remove the white spaces?
Use the String. replace() method to remove all whitespace from a string, e.g. str. replace(/\s/g, '') . The replace() method will remove all whitespace characters by replacing them with an empty string.
To remove whitespace characters from the beginning or from the end of a string only, you use the trimStart() or trimEnd() method.
String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.
Liquid is a templating language used in Jekyll to process your site's pages. In other words, it helps you make your HTML pages a bit more dynamic, for example adding logic or using content from elsewhere. This doesn't require any setup - we can just start using it.
The {{-
and {%-
tags exist in the latest beta version of Liquid but Jekyll uses the latest stable version, which doesn't include those tags.
When there's a stable release of Liquid 4.0, the next release of Jekyll should include that update and thus those tags will be available to use on Jekyll sites.
Not sure if this is specific to Shopify, but you could try using the strip filter.
Input: {{ " So much room for activities! " | strip }}
Output: So much room for activities!
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