使标签内的逻辑 {% Raw %}...{% Endraw %}

发布于 2025-01-14 13:29:37 字数 317 浏览 4 评论 0原文

shopify中。

我有一些代码包装在 {% raw %}...{% endraw %} 标签中,但我需要通过 if 在该标签内创建逻辑。它是这样的:

{% raw %}
...
{%- if any != 0 -%}...{%- endif -%}
...
{% endraw %}

但是这样逻辑代码就被转义了。 请告诉我如何在 {% raw %}...{% endraw %} 标记内创建逻辑。

感谢。

In shopify.

I have some of the code wrapped in a {% raw %}...{% endraw %} tag, but I need to make logic through if inside that tag. It goes like this:

{% raw %}
...
{%- if any != 0 -%}...{%- endif -%}
...
{% endraw %}

But this way the logic code is escaped.
Please tell me how I can make the logic inside the {% raw %}...{% endraw %} tags.

Thank.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

妖妓 2025-01-21 13:29:38

你不能。

{% raw %} 标签的整体思想是忽略其中的任何流动代码,以防止与其他语言的语法冲突。

如果你想执行任何代码,你必须将其写在原始标签之外。

或者简单地说:

{% raw %}
...
{% endraw %}
{%- if any != 0 -%}...{%- endif -%}
{% raw %}
...
{% endraw %}

You can't.

The whole idea of a {% raw %} tag is to ignore any liquid code inside of it to prevent syntax conflict with other languages.

If you want to execute any code you have to write it outside the raw tag.

Or to say it simply:

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