在 Liquid 中显示 html 格式
我一直在寻找实现我想要实现的目标的解决方案。
我想要的是将一些 html 文本插入到 Liquid html 文件中,例如我收到了一些 HTML 文本并将其用作代码中的变量。
这是我想要实现的一个片段:
{% assign name = "<b>liquid</b>" %}
{{ name }}
我有一个 var 名称,其中包含 HTML 字符串,我想将其显示为:
liquid
但相反,我得到的只是 液体<./b> (没有点,我仍然是新发帖)。
我知道“strip_html”存在,因此 HTML 标签被删除并保留文本,但我想保留字符串中的 HTML 格式。
有可能吗? 谢谢!
I've been looking for a while for a solution to what I want to achieve.
What I want is to insert some html text into a Liquid html file, for example I have some HTML text I received and use it as a variable in my code.
Here is a snippet of what I want to achieve:
{% assign name = "<b>liquid</b>" %}
{{ name }}
I have a var name with a HTML string in it, and i want to show it as:
liquid
but instead, all I get is <b.>liquid<./b> (without dots, I'm still new posting here).
I know that "strip_html" exists so HTML tags are removed and I keep the text, but I want to keep the HTML format from the string.
Is it even possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我知道如何让它发挥作用。
我只需要将 html 部分放在捕获标记内即可。对于上面的例子,它会是这样的:
它有效,html 正确显示。
感谢 Tasawer Khan 的回答!我希望它对其他人有用。
Ok I figured it out how make it work.
I just had to put the html part inside a capture tag. With the example above it would be like:
And it works, the html is correctly displayed.
Thanks to Tasawer Khan for the answer! I hope it's useful for someone else.
您可以通过替换 <<,在网站或网页上将 HTML 标签显示为 HTML 中的纯文本。与 <或 &60;和>与 >或 &62;在您希望可见的每个 HTML 标记上
You can show HTML tags as plain text in HTML on a website or webpage by replacing < with < or &60; and > with > or &62; on each HTML tag that you want to be visible