我有这段代码:
{% set pageDescription = item.description|length > 197 ? item.description|striptags|trim|slice(0, 197) ~ '...' : item.description %}
我将从item.description中删除新行
例子我有
<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..." />
更改为
<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..." />
我该怎么做?
谢谢。
答案 0 :(得分:10)
试试
|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""})
答案 1 :(得分:2)
如果您只需要html标记,则spaceless {% spaceless %} ... {% endspaceless %}
就足够了