mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
added some tests for the use tag
This commit is contained in:
+5
-1
@@ -1470,6 +1470,9 @@ http://github.com/fabpot/Twig-extensions.
|
||||
Horizontal Reuse
|
||||
----------------
|
||||
|
||||
.. versionadded:: 1.1
|
||||
Horizontal reuse was added in Twig 1.1.
|
||||
|
||||
.. note::
|
||||
|
||||
Horizontal reuse is an advanced Twig feature that is hardly ever needed in
|
||||
@@ -1509,7 +1512,8 @@ The ``use`` statement tells Twig to import the blocks defined in
|
||||
{% block sidebar %}{% endblock %}
|
||||
|
||||
In this example, the ``use`` statement imports the ``sidebar`` block into the
|
||||
main template. The code is exactly equivalent to the following one:
|
||||
main template. The code is mostly equivalent to the following one (the
|
||||
imported blocks are not outputted automatically):
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class Twig_Node_Module extends Twig_Node
|
||||
->indent()
|
||||
;
|
||||
|
||||
for ($i = count($this->getNode('traits')) - 1; $i >= 0; --$i) {
|
||||
for ($i = 0, $count = count($this->getNode('traits')); $i < $count; $i++) {
|
||||
$compiler
|
||||
->write(sprintf("\$_trait_%s_blocks,\n", $i))
|
||||
;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
"use" tag
|
||||
--TEMPLATE--
|
||||
{% use "blocks.twig" with content as foo %}
|
||||
|
||||
{{ block('foo') }}
|
||||
--TEMPLATE(blocks.twig)--
|
||||
{% block content 'foo' %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
foo
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
"use" tag
|
||||
--TEMPLATE--
|
||||
{% use "blocks.twig" %}
|
||||
|
||||
{{ block('content') }}
|
||||
--TEMPLATE(blocks.twig)--
|
||||
{% block content 'foo' %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
foo
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
"use" tag
|
||||
--TEMPLATE--
|
||||
{% use "foo.twig" %}
|
||||
|
||||
{{ block('content') }}
|
||||
{{ block('foo') }}
|
||||
{{ block('bar') }}
|
||||
--TEMPLATE(foo.twig)--
|
||||
{% use "bar.twig" %}
|
||||
|
||||
{% block content 'foo' %}
|
||||
{% block foo 'foo' %}
|
||||
--TEMPLATE(bar.twig)--
|
||||
{% block content 'bar' %}
|
||||
{% block bar 'bar' %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
foo
|
||||
foo
|
||||
bar
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
"use" tag
|
||||
--TEMPLATE--
|
||||
{% use "foo.twig" %}
|
||||
{% use "bar.twig" %}
|
||||
|
||||
{{ block('content') }}
|
||||
{{ block('foo') }}
|
||||
{{ block('bar') }}
|
||||
--TEMPLATE(foo.twig)--
|
||||
{% block content 'foo' %}
|
||||
{% block foo 'foo' %}
|
||||
--TEMPLATE(bar.twig)--
|
||||
{% block content 'bar' %}
|
||||
{% block bar 'bar' %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
bar
|
||||
foo
|
||||
bar
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
"use" tag
|
||||
--TEMPLATE--
|
||||
{% use "foo.twig" with content as foo_content %}
|
||||
{% use "bar.twig" %}
|
||||
|
||||
{{ block('content') }}
|
||||
{{ block('foo') }}
|
||||
{{ block('bar') }}
|
||||
{{ block('foo_content') }}
|
||||
--TEMPLATE(foo.twig)--
|
||||
{% block content 'foo' %}
|
||||
{% block foo 'foo' %}
|
||||
--TEMPLATE(bar.twig)--
|
||||
{% block content 'bar' %}
|
||||
{% block bar 'bar' %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
bar
|
||||
foo
|
||||
bar
|
||||
foo
|
||||
Reference in New Issue
Block a user