@@ -951,6 +951,11 @@ When overriding the ``alert_message`` block, you have access to the ``message``
951
951
{% endblock %}
952
952
{% endcomponent %}
953
953
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
+
954
959
As mentioned before, variables from lower components are merged with those from upper components. When you need
955
960
access to some properties or functions from higher components, that can be done via the ``outerScope... `` variable:
956
961
@@ -960,18 +965,15 @@ access to some properties or functions from higher components, that can be done
960
965
{% set name = 'Fabien' %}
961
966
{% set message = 'Hello' %}
962
967
{% component Alert with { type: 'success', name: 'Bart' } %}
963
- Hello {{ name }} {# name = Bart #}
968
+ Hello {{ name }} {# Hello Bart #}
964
969
965
- {{ message }} {{ outerScope.name }} {# message = ' Hello', name = Fabien #}
970
+ {{ message }} {{ outerScope.name }} {# Hello Fabien #}
966
971
967
972
{{ outerScope.this.someFunction }} {# this refers to SuccessAlert #}
968
973
969
974
{{ outerScope.this.someProp }} {# references a "someProp" prop from SuccessAlert #}
970
975
{% endcomponent %}
971
976
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
-
975
977
You can keep referring to components higher up as well. Just add another ``outerScope ``.
976
978
Remember though that the ``outerScope `` reference only starts once you're INSIDE the (embedded) component.
977
979
@@ -989,10 +991,6 @@ Remember though that the ``outerScope`` reference only starts once you're INSIDE
989
991
{% endblock %}
990
992
{% endcomponent %}
991
993
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
-
996
994
Component HTML Syntax
997
995
---------------------
998
996
0 commit comments