From f42664e3ad03dc2241179dce9f81608acb646934 Mon Sep 17 00:00:00 2001 From: Caleb Mah Date: Mon, 3 Oct 2022 21:35:38 +0800 Subject: [PATCH] Clarify scripts example for scope of variables (#24336) --- source/_docs/scripts.markdown | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/_docs/scripts.markdown b/source/_docs/scripts.markdown index bd7aa752e95..f0056fb0cbc 100644 --- a/source/_docs/scripts.markdown +++ b/source/_docs/scripts.markdown @@ -95,7 +95,7 @@ Variables can be templated. Variables have local scope. This means that if a variable is changed in a nested sequence block, that change will not be visible in an outer sequence block. -The following example will always say "There are 0 people home". Inside the `if` sequence the `variables` action will only alter the `people` variable for that sequence. +Inside the `if` sequence the `variables` action will only alter the `people` variable for that sequence. {% raw %} @@ -114,11 +114,13 @@ sequence: - variables: people: "{{ people + 1 }}" # At this scope, people will now be 1 ... + - service: notify.notify + data: + message: "There are {{ people }} people home" # "There are 1 people home" # ... but at this scope it will still be 0 - # Announce the count of people home - service: notify.notify data: - message: "There are {{ people }} people home" + message: "There are {{ people }} people home" # "There are 0 people home" ``` {% endraw %}