Shopify 液体。如果 line.title 包含 '<br>' 语句不起作用

Shopify Liquid. If line.title contains '<br>' statement is not working

我们正在使用 Shopify,我们有一个显示产品标题和其他数据的发票页面。

我的问题是 product.title 在发票页面上显示 <br> 标签。
(在产品页面标题上显示 w/o <br> 标签)

原因是product.title只能通过所见即所得的方式输入。
其中所见即所得将product.title编码为ASCII码并在发票页面上解码product.title .

我正在尝试使用带有 {% if %} 语句的 Liquid 字符串过滤器
{{ product.title | replace: 'Awesome', 'Mega' }}product.title 中查找和 replace/hide <br> 标签,并且它不工作。如果我将 {% if line.title contains '<br>'%} 更改为 {% if line.title contains 'Dress'%},代码将用白色 space.
替换 Dress 请在下面找到我的代码的一部分。

我添加的部分代码

{% if line.title contains '<br>'%} {{ line.title | replace: '<br>', ' ' }} {% endif %}

通用代码

<td class="order-list__product-description-cell" style="width:100%">
  {% if line.product.title %} {% assign line_title = line.product.title %} 
  {% else %} {% assign line_title = line.title %} {% endif %}
  <span class="order-list__item-title">

 <!-- Replace if statement -->

  {% if line.title contains '<br>'%} {{ line.title | replace: '<br>', ' ' }}
  {% endif %} 

  <!-- Replace if statement -->

  {{ line_title }} × {{ line.quantity }}
</span>
<br/> {% if line.variant.title != 'Default Title' %}
<span class="order-list__item-variant">{{ line.variant.title }}</span> {% endif %}

如果您能告诉我我做错了什么并指导我如何以正确的方式实施它,我将不胜感激。 同时等待 Shopify 解决在其应用中显示标签的问题

如果您的标题是这样显示的:

这是一个非常、非常、非常、
非常长的产品标题!

然后 Shopify 可能正在转义您的 HTML 标签,将其变成这个 under-the-hood:

这是一个非常、非常、非常、<br>非常长的产品标题!

如果您将 {{ product.title }} 代码更新为:{{ product.title | replace: '&lt;', '<' | replace: '&gt;', '>' }} 您应该得到以下内容:

这是真的,真的,真的,

好长的产品标题!

或者,如果您想完全删除换行符,您可以使用:

{{ product.title | replace: '&lt;', '<' | replace: '&gt;', '>' | remove: '<br>' }}

或: {{ product.title | replace: '&lt;br&gt;', ' ' }}