I have two Jekyll collections, one references the other via an attribute. Here's a simple example:
---
# product
id: my-awesome-product
name: My Awesome Product
sizes:
- sm
- md
- lg
---
---
# size
id: sm
price: $10.00
---
... etc. for md and lg
The collections are exposed to Liquid as arrays, not hashes, so some array walking needs to be done in order to find a given size by its ID. Ideally, I'd like to be able to create a Liquid tag that returns the size document for me to display as needed. In other words, I'd like to do something like this:
{% for product in site.products %}
{{ product.name }}
{% for s in product.sizes %}
{% size s %} # how do I create a Liquid Tag that starts like this,
* {{ size.id }} ({{ size.price }}) # looks up and grants access to a size
{% endsize %} # and ends liks this
{% endfor %}
{% endfor %}