I have this code:
{% set pageDescription = item.description|length > 197 ? item.description|striptags|trim|slice(0, 197) ~ '...' : item.description %}
I will remove new lines from item.description
example I have
<meta name="description" content="An easy playing game about the natural numbers. There will randomly appear the natural. You have to choose what the right after number is. It&#8217;s so easy to play this game, isn&#8217;t it?
The..." />
change to
<meta name="description" content="An easy playing game about the natural numbers. There will randomly appear the natural. You have to choose what the right after number is. It&#8217;s so easy to play this game, isn&#8217;t it? The..." />
How I can do?
Thank you.
Try using the |replace
filter.
|replace({"\n": "", "\r": "", "\t": ""})
For example
{{ item.description|replace({"\n": "", "\r": "", "\t": ""}) }}
If you need it only html tag maybe the spaceless {% spaceless %} ... {% endspaceless %}
would be enough
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