【问题标题】:Shopify template ''if tage was never closed'Shopify 模板“如果标签从未关闭”
【发布时间】:2021-05-13 08:51:23
【问题描述】:

如果存在第二张图像,则尝试获取液体以添加类 has_second_image 但是当我运行 yarn start 时,终端会吐出“如果标签从未关闭”

  {% liquid 
   assign has_second_image = false
  
    if product.images[1]
     assign has_second_image = true
    endif 
  %}

<a  href="{{ product.url }}" class="product-tile{% if has_second_image %} product-tile-has-second-image{% endif %}">
  <div class="product-tile_image-wrapper"{% if has_second_image %} style= "background-image: url({{ product.images[1] | img_url: '700x' }});">
    <img class="product-tile_image" src="{{ product.featured_image | img_url: '700x' }}" alt="{{ product.featured_image.alt }}" />
  </div>
  <div class="product-tile_info">
    <h3 class="product-tile_title"> {{ product.title }}</h3>
    <span class="product-tile_price">{{ product.price | money }}</span>
  </div>
</a>

【问题讨论】:

    标签: layout themes shopify liquid


    【解决方案1】:

    您没有在您发布的代码的第 10 行关闭您的 if 语句:

    <div class="product-tile_image-wrapper"{% if has_second_image %} style= "background-image: url({{ product.images[1] | img_url: '700x' }});">
    

    这应该可以解决它:

    <div class="product-tile_image-wrapper"{% if has_second_image %} style= "background-image: url({{ product.images[1] | img_url: '700x' }});"{% endif %}>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-28
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多