在 Liquid 中显示 html 格式

发布于 2025-01-09 01:09:45 字数 420 浏览 5 评论 0原文

我一直在寻找实现我想要实现的目标的解决方案。

我想要的是将一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疯了 2025-01-16 01:09:45

好吧,我知道如何让它发挥作用。

我只需要将 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:

{% capture name %} <b>liquid</b> {% end capture %}

And it works, the html is correctly displayed.
Thanks to Tasawer Khan for the answer! I hope it's useful for someone else.

稚然 2025-01-16 01:09:45

您可以通过替换 <<,在网站或网页上将 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文