Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andreibabor/df2a281ad745befadfb8744553204f8c to your computer and use it in GitHub Desktop.
Save andreibabor/df2a281ad745befadfb8744553204f8c to your computer and use it in GitHub Desktop.
split collection description in 2 paragraphs
//alt code smecher de la un client
{% assign descriptions = product.description | split: "<h5>" %}
{% for description_block in descriptions %}
{% if forloop.first == true %}
{{ description_block }}
{% else %}
{% assign split_block = description_block | split: "</h5>" %}
<div class="accordion" id="section{{forloop.index}}">
<h5>{{ split_block[0] }}</h5>
</div>
<div class="content">
{{ split_block[1] }}
</div>
{% endif %}
{% endfor %}
{% assign descriptions = collection.description | split: "<!-- split -->" %}
{% assign short_desc = descriptions[0] %}
{% assign long_desc = descriptions[1] %}
Then put the individual descriptions whereever you want them on the page with
{{ short_desc }} and {{ long_desc }}, respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment