sonterix
11/17/2018 - 1:36 PM

Tabs from description

{% if product.description contains '[TABS]' %}
  {% assign product_reviews_tab_index = false %}
  {% assign  tabsContent = product.description | split: "[TABS]" | last | remove: "[/TABS]"%}
  {% assign tabsContentArray = tabsContent | split: "<h5>" %}
   {% capture tabsContentArrayNoBlank %} 
   {% for part in tabsContentArray %}
 {% if part != blank %}{{ part }}___{% endif %}
    {% endfor %}
    {% endcapture %}
   {% assign tabsContentArrayFormated = tabsContentArrayNoBlank | split: "___"%}
  <div class="tabing">
     <ul class="nav nav-tabs"> 
       {% for part in tabsContentArrayFormated %}
           {% if part != blank %}
             {% assign title_part = part | split: "</h5>" | first %}
             {% if title_part contains "Reviews" %}
              {% assign product_reviews_tab_index = forloop.index %}
             {% endif %}
             <li class="{% if forloop.first %} active{% endif %}"><a href="#tab{{forloop.index}}" data-toggle="tab">{{ title_part }}</a></li>
         {% endif %}
       {% endfor %}
    </ul>

   <div class="tab-content">           
     {% for part in tabsContentArrayFormated %}
       {% if part != blank %}
         {% assign content_part = part | split: "</h5>" | last %}

         <div class="tab-pane {% if forloop.first %} active{% endif %}" id="tab{{forloop.index}}">
           {% if forloop.index == product_reviews_tab_index %}
             {% if section.settings.product_reviews %}  
               {% comment %} This is place for reviews app code {% endcomment %}
               <div id="shopify-product-reviews" data-id="{{ product.id }}">{{ product.metafields.spr.reviews }}</div> 
             {% else %}
               <div class="rte">
                 {{content_part}}
               </div>
             {% endif %}
           {% else %}
             <div class="rte">
               {{content_part}}
             </div>
           {% endif %}
         </div>
     
     	{% endif %}
     {% endfor %}
     
    </div>

  </div> 
{% endif %}