Squeeze is a Statamic addon that provides a modifier named squeeze
which removes a bunch of characters from a given
string by replacing them with an empty string.
This addon removes the following characters by default:
_
-
/
:
You can search for this addon in the Tools > Addons
section of the Statamic control panel and click install, or
run the following command from your project root:
composer require doefom/squeeze
In your .yaml
files you probably have some kind of string variable like this:
text: "A_string-to/test:the squeeze"
Then you can use the modifier in your antlers views like this:
{{ text | squeeze }}
Which outputs:
Astringtotestthesqueeze
You may also pass your own squeezables to the modifier like so:
{{ text | squeeze:":-(" }}
It's also possible to squeeze whitespaces but they cannot be the last character of the squeezables string:
{{ text | squeeze:"-_ :(" }} // This will work
{{ text | squeeze:" -_:(" }} // This will work
{{ text | squeeze:"-_:( " }} // This will not work
Also, if you want to squeeze backslashes you'll need to escape them:
{{ text | squeeze:"\\" }} // This squeezes a backslash