Skip to content

Commit b57e4a5

Browse files
committed
Tweaked documentation
1 parent 6ac23cb commit b57e4a5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/TwigComponent/doc/index.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,11 @@ When overriding the ``alert_message`` block, you have access to the ``message``
951951
{% endblock %}
952952
{% endcomponent %}
953953
954+
955+
.. versionadded:: 2.12
956+
957+
The ability to refer to the scope of higher components via the ``outerScope`` variable was added in 2.12.
958+
954959
As mentioned before, variables from lower components are merged with those from upper components. When you need
955960
access to some properties or functions from higher components, that can be done via the ``outerScope...`` variable:
956961

@@ -960,18 +965,15 @@ access to some properties or functions from higher components, that can be done
960965
{% set name = 'Fabien' %}
961966
{% set message = 'Hello' %}
962967
{% component Alert with { type: 'success', name: 'Bart' } %}
963-
Hello {{ name }} {# name = Bart #}
968+
Hello {{ name }} {# Hello Bart #}
964969
965-
{{ message }} {{ outerScope.name }} {# message = 'Hello', name = Fabien #}
970+
{{ message }} {{ outerScope.name }} {# Hello Fabien #}
966971
967972
{{ outerScope.this.someFunction }} {# this refers to SuccessAlert #}
968973
969974
{{ outerScope.this.someProp }} {# references a "someProp" prop from SuccessAlert #}
970975
{% endcomponent %}
971976
972-
To keep the generic Alert component unaware of the ``someProp`` prop it is better to use ``outerScope.this``
973-
instead of passing that info along via Alert's attributes.
974-
975977
You can keep referring to components higher up as well. Just add another ``outerScope``.
976978
Remember though that the ``outerScope`` reference only starts once you're INSIDE the (embedded) component.
977979

@@ -989,10 +991,6 @@ Remember though that the ``outerScope`` reference only starts once you're INSIDE
989991
{% endblock %}
990992
{% endcomponent %}
991993
992-
.. versionadded:: 2.12
993-
994-
The ability to refer to the scope of higher components via the ``outerScope`` variable was added in 2.12.
995-
996994
Component HTML Syntax
997995
---------------------
998996

0 commit comments

Comments
 (0)