@@ -738,6 +738,8 @@ There is also a non-HTML syntax that can be used:
738738 {% block footer %}... footer content{% endblock %}
739739 {% endcomponent %}
740740
741+ .. _embedded-components-context :
742+
741743Context / Variables Inside of Blocks
742744~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
743745
@@ -801,10 +803,7 @@ When overriding the ``alert_message`` block, you have access to the ``message``
801803 </twig:block>
802804 </twig:SuccessAlert>
803805
804- .. versionadded :: 2.13
805-
806- The ability to refer to the scope of higher components via the ``outerScope ``
807- variable was added in 2.13.
806+ .. _embedded-components-outerScope :
808807
809808As mentioned before, variables from lower components are merged with those from
810809upper components. When you need access to some properties or functions from higher
@@ -825,6 +824,11 @@ components, that can be done via the ``outerScope...`` variable:
825824 {{ outerScope.this.someProp }} {# references a "someProp" prop from SuccessAlert #}
826825 {% endcomponent %}
827826
827+ .. versionadded :: 2.13
828+
829+ The ability to refer to the scope of higher components via the ``outerScope ``
830+ variable was added in 2.13.
831+
828832You can keep referring to components higher up as well. Just add another ``outerScope ``.
829833Remember though that the ``outerScope `` reference only starts once you're INSIDE the (embedded) component.
830834
@@ -842,6 +846,8 @@ Remember though that the ``outerScope`` reference only starts once you're INSIDE
842846 {% endblock %}
843847 {% endcomponent %}
844848
849+ .. _embedded-components-outerBlocks :
850+
845851Inheritance & Forwarding "Outer Blocks"
846852~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
847853
@@ -1563,9 +1569,33 @@ listen to ``PreMountEvent`` or ``PostMountEvent``.
15631569Nested Components
15641570-----------------
15651571
1566- It's totally possible to include components as part of the contents of another
1567- component. When you do this, all components render independently. The only
1568- caveat is that you cannot mix the Twig syntax and the :ref: `HTML syntax <component_html_syntax >`
1572+ It’s possible to include components inside another component:
1573+
1574+ .. code-block :: twig
1575+
1576+ <twig:SomeComponent>
1577+ {% for i in 1..10 %}
1578+ <twig:AnotherComponent>
1579+ {{ i }}
1580+ </twig:AnotherComponent>
1581+ {% endfor %}
1582+ </twig:SomeComponent>
1583+
1584+ When you do this, each component is rendered independently, but there are some
1585+ important caveats:
1586+
1587+ #. As :ref: `explained above <embedded-components-context >`, the variables of a
1588+ component are merged with the variables of its parent component. Variables
1589+ with the same name (e.g. ``this `` or ``computed ``) are overridden by the
1590+ inner component;
1591+ #. The original parent component variables are available via the special
1592+ :ref: `outerScope variable <embedded-components-outerScope >`, so you can, for
1593+ example, call ``outerScope.this.someFunction() ``;
1594+ #. The contents of blocks defined in parent components are avaialble via the
1595+ special :ref: `outerBlocks variable <embedded-components-outerBlocks >`, so you
1596+ can call ``block(outerBlocks.someBlockName) ``.
1597+
1598+ Finally, you cannot mix the Twig syntax and the :ref: `HTML syntax <component_html_syntax >`
15691599when using nested components:
15701600
15711601.. code-block :: html+twig
@@ -1599,8 +1629,9 @@ when using nested components:
15991629 {% endblock %}
16001630 {% endcomponent %}
16011631
1602- If you're using `Live Components `_, then there *are * some guidelines related to
1603- how the re-rendering of parent and child components works. Read `Live Nested Components `_.
1632+ If you're using `Live Components `_, there *are * additional guidelines related
1633+ to how parent and child components are re-rendered. See `Live Nested Components `_
1634+ for details.
16041635
16051636Configuration
16061637-------------
0 commit comments