Created
May 13, 2013 12:18
-
-
Save marekkalnik/5567913 to your computer and use it in GitHub Desktop.
utilisation d'un macro pour une fonction récursive dans Twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% import _self as brandOrder %} | |
{% extends 'TheodoDemoBundle::base.html.twig' %} | |
{% macro brandOrder(brand) %} | |
<li class="nav level{{ brand.treeLevel }} more"> | |
<div id="brand{{ brand.id }}"><span>{{ brand.title }}</span></div> | |
{% if brand.children|length > 0 %} | |
{% import _self as brandHelper %} | |
<ul> | |
{% for brandChildren in brand.childrenOrdered %} | |
{{ brandHelper.brandOrder(brandChildren) }} | |
{% endfor %} | |
</ul> | |
{% endif %} | |
</li> | |
{% endmacro %} | |
{% block content %} | |
<div class="span6 right"> | |
<h3>Les marques</h3> | |
<ul id="brand-list" class="brand nav nav-pills nav-stacked"> | |
{% for brand in brands %} | |
{{ brandOrder.brandOrder(brand) }} | |
{% endfor %} | |
</ul> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment