K
K
Karen Mnatsakanyan2017-11-21 00:36:48
Twig
Karen Mnatsakanyan, 2017-11-21 00:36:48

How to print twig array?

Hi all!
There is a cycle

{% for category in categories %}
          <li class="header-main-menu__item">
            <a class="header-main-menu__link header-main-menu__item_font " href="{{ category.href }}">{{ category.name }}</a>
          </li>
        {% endfor %}

How can I print the category array? type print_r

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2017-11-21
@karjan

If you look at the documentation , you can find a wonderful function {{ dump(user) }}, it is a wrapper for php var_dump . To make it work, you need to enable debug mode for Twig.

$twig = new Twig_Environment($loader, array(
    'debug' => true,
    // ...
));
$twig->addExtension(new Twig_Extension_Debug());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question