【问题标题】:Concatenate string with html in liquid Shopify在液体 Shopify 中将字符串与 html 连接起来
【发布时间】:2023-01-12 17:33:26
【问题描述】:
{% assign price = product.price | money %}
{% capture dot_separator %} <span class='Button__SeparatorDot'></span> {% endcapture %}
{% capture addToCartText %} ADD TO CART {{ dot_separator }} {{ product_price_formatted }} {% endcapture %}
 
{{ addToCartText }}

我的目标是以这种方式显示“添加到购物车文本”文本

目标:添加到购物车 。 287$

使用 css 创建点的位置

现在是这样显示的

当前输出:添加到购物车 <span class='Button__SeparatorDot'></span> 287 美元

我如何告诉 liquid 按原样阅读 html?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    尝试使用strip_html过滤器https://shopify.github.io/liquid/filters/strip_html/

    像这样:

    {% capture dot_separator %} < span class='Button__SeparatorDot'></ span> {% endcapture %}
    {% capture addToCartText %} ADD TO CART {{ dot_separator | strip_html }} {{ product_price_formatted }} {% endcapture %}
     
    {{ addToCartText }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-20
      相关资源
      最近更新 更多