I'm trying to build a product list from products.yml
located in the _data directory with a for loop
in jekyll so that the end result would look like this: example built with handlebars.js
First I wrote a YAML file in _data/products.yml
with a list of products divided into categories
---
categories:
- Baking Products:
- name: Vegetable oil
- name: Vinegar
- ...
- Dairy Products:
- name: Cream Cheese
- name: Cottage Cheese
- ...
- Other Products:
- name: Peanut butter
- name: Chocolate spread
- ...
Now I want to iterate over all categories, and for evry cateory to iterate over all its products and displaying some info about them:
{% for category in site.data.products %}
<div class="plist">
<div class="category">
<h3>{{ category.name }</h3>
<span>Qty</span>
</div>
{% for product category.products %}
<div class="product checkbox">
<input type="checkbox" id="{{ product.name | capitalize }}" value="{{ product.name }}">
<label for="{{ product.name | capitalize }}">{{name}}</label>
<select name="{{ product.name }}" id="{{ product.name | capitalize }}Q" autocomplete="off" class="dropdown">
<option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>
</select>
</div>
{% endfor %}
</div>
{% if loop.index0 % 2 == 0 %}
<break></break>
{% endif %}
{% endfor %}
getting this error:
Liquid Exception: Liquid syntax error (line 13): Variable '{{ category.name }' was not properly terminated with regexp: /}}/ in order.html
jekyll 3.8.5 | Error: Liquid syntax error (line 13): Variable '{{ category.name }' was not properly terminated with regexp: /}}/
<h3>{{ category.name }</h3>
– ashmaroli{{ category.name }}
– ashmaroliLiquid Exception: Liquid syntax error (line 16): Syntax Error in 'for loop' - Valid syntax: for [item] in [collection] in order.html jekyll 3.8.5 | Error: Liquid syntax error (line 16): Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]
– Meir Roth