PHP Classes

File: Library/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test

Recommend this page to a friend!
  Classes of Duong Huynh Nghia   Lego PHP   Library/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test   Download  
File: Library/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Lego PHP
Blog and shopping cart system
Author: By
Last change:
Date: 7 years ago
Size: 1,171 bytes
 

Contents

Class file image Download
--TEST-- "block" function recursively called in a parent template --TEMPLATE-- {% extends "ordered_menu.twig" %} {% block label %}"{{ parent() }}"{% endblock %} {% block list %}{% set class = 'b' %}{{ parent() }}{% endblock %} --TEMPLATE(ordered_menu.twig)-- {% extends "menu.twig" %} {% block list %}{% set class = class|default('a') %}<ol class="{{ class }}">{{ block('children') }}</ol>{% endblock %} --TEMPLATE(menu.twig)-- {% extends "base.twig" %} {% block list %}<ul>{{ block('children') }}</ul>{% endblock %} {% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %} {% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %} {% block label %}{{ item }}{{ block('unknown') }}{% endblock %} --TEMPLATE(base.twig)-- {{ block('list') }} --DATA-- return array('item' => array('1', '2', array('3.1', array('3.2.1', '3.2.2'), '3.4'))) --EXPECT-- <ol class="b"><li>"1"</li><li>"2"</li><li><ol class="b"><li>"3.1"</li><li><ol class="b"><li>"3.2.1"</li><li>"3.2.2"</li></ol></li><li>"3.4"</li></ol></li></ol>