File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -841,6 +841,24 @@ Inheritance & Forwarding "Outer Blocks"
841
841
842
842
The ``outerBlocks `` variable was added in 2.10.
843
843
844
+ Consider this simple example to explain the basic usage of ``outerBlocks `` which serves as a
845
+ means to refer to blocks defined in the same template:
846
+
847
+ .. code-block :: html+twig
848
+
849
+ {% extends 'base.html.twig' %}
850
+
851
+ {% block call_to_action %}<strong>Attention! Free Puppies!</strong>{% endblock %}
852
+
853
+ {% block body %}
854
+ {% component Alert %}
855
+ {% block content %}{{ block(outerBlocks.call_to_action) }}{% endblock %}
856
+ {% endcomponent %}
857
+ {% endblock %}
858
+
859
+ Although this is not a super practical example. The ``outerBlocks `` variable becomes a lot
860
+ more useful with nested components.
861
+
844
862
When passing blocks via the ``{% component %} `` syntax, there is one important thing
845
863
to understand: the content behaves as if it lives in its **own **, independent template,
846
864
which extends the component's template.
You can’t perform that action at this time.
0 commit comments