reggi / shopify

Just a place to track issues and feature requests that I have for shopify
3 stars 1 forks source link

Key / Value shopify tags. #3

Open reggi opened 9 years ago

reggi commented 9 years ago

screen shot 2015-02-04 at 12 56 47 pm

Usage

{% assign pass_array = article.tags %}
{% assign pass_key = "author_info" %}
{% include "function.tag_key" %}
{% assign article_author_bio = return %}

function.tag_key

{% assign return = false %}
{% if pass_array %}
    {% if pass_key %}
        {% for item in pass_array %}
            {% assign parts = item | split:":" %}
            {% assign key = parts[0] %}
            {% assign value = parts[1] %}
            {% if pass_key == key %}
                {% assign pass_key = pass_key | append:":" %}
                {% assign value = item | remove:pass_key %}
                {% assign return = value %}
            {% endif %}
       {% endfor %}
    {% endif %}
{% endif %}
reggi commented 9 years ago

Note: I've stopped adding periods in snippet names because you can't access the with variable. This won't work:

{% include function.tag_key with "author_info" %}