簡體   English   中英

在液體 Shopify 中將字符串與 html 連接起來

[英]Concatenate string with html in liquid Shopify

{% 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 }}

我的目標是以這種方式顯示“addToCartText”文本

目標:加入購物車。 287$

使用 css 創建點的位置

現在是這樣顯示的

當前 output:加入購物車 <span class='Button__SeparatorDot'></span> 287$

我如何告訴 liquid 按原樣讀取 html?

嘗試使用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 }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM