Answer the question
In order to leave comments, you need to log in
How to count the number of values in YML using Liquid?
There is an advertisers.yml YML file.
You need to count the number of campaigns with status = 1
- login: ivanivanov
name: Иван Иванов
campaigns:
- name: Кампания Ивана Иванова
status_id: 1
- name: Вторая кампания Ивана Иванова
status_id: 2
- login: ivanpetrov
name: Иван Петров
campaigns:
- name: Кампания Ивана Петрова
status_id: 1
- login: ivansidorov
name: Иван Сидоров
campaigns:
- name: Кампания Сидорова
status_id: 3
{% assign advertiser = site.data.advertisers %}
{% assign campaign = advertiser.campaigns %}
{% if campaign.status_id == 1 %}
{{ campaign.status_id | size }}
{% endif %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question