0
votes

I have a list of products, each with a list of features of nested yaml lists

- product: Product n1
  features:
  - feature1
  - feature2
  - feature3

- product: Product n2
  features:
  - feature1
  - feature2

- product: Product n3
  features:
  - feature1
  - feature2
  - feature3
  - feature4
  - feature5

Goal: create a list of divs, one for each product, with a title and the list of features.

I tried using for subitem in item but I can't get it to work - any ideas?

1

1 Answers

0
votes

I solved the problem with the following code:

{% for product in site.data.products %}

  <div>

    <h2>{{ product.product }}</h2>

    <ul>

      {% for feature in product.features %}
        <li>{{ feature }}</li>
      {% endfor %}

    </ul>

  </div>

{% endfor %}