Answer the question
In order to leave comments, you need to log in
Can't figure out how to validate an array in twig?
Here is a macro slightly modified from a similar stackoverflow question
{% macro menu(links) %}
{% for key, link in links %}
<li>
<a href="{{ link }}">{{ key }}</a>
{% if link.sublink %}
<ul>
{{ _self.menu_links(link[key]) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
Главная: /
Контакты: /contacts
Форум: /forum
О нас: /about
Услуги:
Услуга1: /one
Услуга2: /two
Answer the question
In order to leave comments, you need to log in
Here's what I came up with, it should work as expected:
{% if (link|keys)|length>0 %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question