Created
February 24, 2015 08:52
-
-
Save oksushi/ce2c293b9c6718ad16f3 to your computer and use it in GitHub Desktop.
Tabs using Liquid in Shopify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if product-description-tabs %} | |
{% assign description = product-description-tabs %} | |
{% capture description %}{{ description }} 重量: {{variant.weight | weight_with_unit }} <br> 編號: {{variant.sku }}{% endcapture %} | |
{% else %} | |
{% assign description = product.description %} | |
{% capture description %}{{ description }} 重量: {{variant.weight | weight_with_unit }} <br> 編號: {{variant.sku }}{% endcapture %} | |
{% endif %} | |
{% if description %} | |
<link href="/apps/tabs/css" rel="stylesheet" type="text/css" media="all" /> | |
<script type="text/javascript" src="/apps/tabs/js"></script> | |
<div class="description" id="tabs" itemprop="description"> | |
<ul> | |
{% assign first_paragraph = description | split: "<h5" | first %}{% assign fp = first_paragraph %} | |
{% assign first_paragraph = first_paragraph | strip_html | replace: " ", "" | replace: " ", "" | strip_newlines %} | |
{% if first_paragraph != "" or fp contains "<img " %} | |
{% assign ind = 1 %} | |
<li><a href="#tabs-1">Description</a></li> | |
{% else %} | |
{% assign ind = 0 %} | |
{% endif %} | |
{% assign description_parts = description | split: "<h5" %} | |
{% for part in description_parts %} | |
{% if part contains "</h5>" %} | |
{% assign remove = part | split: ">" | first | append: ">" %} | |
<li><a href="#tabs-{{ forloop.index }}">{{ part | split: "</h5>" | first | strip_html | replace: remove, "" }}</a></li> | |
{% endif %} | |
{% endfor %} | |
</ul> | |
{% assign description_parts = description | split: "<h5" %} | |
{% for part in description_parts %} | |
{% assign fp = part | append: " " | split: "</h5>" | last %} | |
{% assign p = part | append: " " | split: "</h5>" | last | strip_html | replace: " ", "" | replace: " ", "" | strip_newlines %} | |
{% if p != "" or fp contains "<img " or fp contains "<iframe " %} | |
<div id="tabs-{{ forloop.index }}">{{ part | split: "</h5>" | last | replace: "<div", "<span" | replace: "</div", "</span" }}</div> | |
{% endif %} | |
{% endfor %} | |
</div> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment