When execution begins, $ is set to the data argument passed to Execute, that is, to the starting value of dot.
{{with .Inner}}
Outer: {{$.OuterValue}}
Inner: {{.InnerValue}}
{{end}}
docs: ""
vars:
person: peter
managers:
- tom
- jason
- alice
dvars:
- name: var_with_range #extra: {{if pipeline}} T1 {{else if pipeline}} T0 {{end}}
value: "{{range .managers}} x {{end}}"
flags: [vvv]
- name: var_with_range_item
value: "{{range $x:=.managers}} {{$x}} {{end}}"
flags: [vvv]
- name: var_with_range_item_simpler
value: "{{range .managers}} {{.}} {{end}}"
flags: [vvv]
- name: var_to_ref_to_outside_of_range_from_within_range
desc: |
the direct reference to try to access out of scope in range will not work
expect a warning from this execution
value: "{{range $x:=.managers}} {{.person}} {{end}}"
flags: [vvv]
- name: var_directly_ref_to
value: "{{.person}}"
flags: [vvv]
- name: var_to_ref_to_outside_of_range_from_within_range_fixed
desc: |
use $. to access out of scope variable
value: "{{range $x:=.managers}} {{$.person}} {{end}}"
flags: [vvv]
tasks:
- name: task
task:
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0075
Verbose -> vvv
ModuleName -> self
ShellType -> /bin/sh
MaxCallLayers -> 8
Timeout -> 3600000
MaxModuelCallLayers -> 256
EntryTask -> task
ModRepoUsernameRef ->
ModRepoPasswordRef ->
work dir: /up_project/up
-exec task: task
loading [Task]: ./tests/functests/c0075
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
dvar> var_with_range:
" x x x "
-
x x x
dvar> var_with_range_item:
" tom jason alice "
-
tom jason alice
dvar> var_with_range_item_simpler:
" tom jason alice "
-
tom jason alice
template rendering -> template: .:1:26: executing "." at <.person>: can't evaluate field person in type interface {}
WARN:
1:{{range $x:=.managers}} {{.person}} {{end}}
trouble shooting tips:
<incompatible types for comparison>: the variable might not be registered, use -v vvv to see the cache, or use inspect cmd to debug
dvar> var_to_ref_to_outside_of_range_from_within_range:
" "
-
dvar> var_directly_ref_to:
"peter"
-
peter
dvar> var_to_ref_to_outside_of_range_from_within_range_fixed:
" peter peter peter "
-
peter peter peter
Task1: [task ==> task: ]