Ruby 如何在jekyll中删除换行符?
我知道,但它不符合我的要求:Ruby 如何在jekyll中删除换行符?,ruby,jekyll,liquid,Ruby,Jekyll,Liquid,我知道,但它不符合我的要求: {% capture string %} Hello there {% endcapture %} {{ string | strip_newlines }} 输出hellother但我需要Hello那里insead 替换也不起作用,因为您不能放置换行符 {{ string | replace: '\n', ' ' }} 如何用空格替换所有换行符?例如,在元标记中使用。以下是技巧: {% assign description = page.excerpt |
{% capture string %}
Hello
there
{% endcapture %}
{{ string | strip_newlines }}
输出hellother
但我需要Hello那里
insead
替换也不起作用,因为您不能放置换行符
{{ string | replace: '\n', ' ' }}
如何用空格替换所有换行符?例如,在元标记中使用。以下是技巧:
{% assign description = page.excerpt | newline_to_br | strip_newlines | replace: '<br />', ' ' | strip_html | strip | truncatewords: 30 %}
<meta name="description" content="{{ description }}">
{%assign description=page.节选|换行|换行|替换:'
',''换行|换行|换行|换行|换行:'
用br标记替换换行符,然后剥去换行符,然后用空格替换
。剥离html并截断以便在元描述中使用。如果您的代码中有其他一些希望保留的
,则不起作用。