我试图用Liquid模板语言将原始字符串转换为html。我想要做的是转换这样的:这个将文本转换为液体模板中的段落
Hello. This
is a text.
Please convert me.
:
<p>Hello. This<br />
is a text.</p>
<p>Please convert me.</p>
我试了一下
{{ mytextvariable | newline_to_br | replace: "<br />\n<br />", "</p><p>" | replace: "<p></p>", "" | prepend: '<p>' | append: '</p>' }}
,但是这给了我(注双<br />
):
<p>Hello. This<br />
is a text.<br />
<br />
Please convert me.</p>
网站注释
这将用于Shopify网站。
谢谢!这可能会奏效。我应该更具体。我在Shopify上使用Liquid。不要认为他们允许我做新的过滤器。我会试着研究,看看他们是否做。 – iDev247 2012-08-13 17:47:18