-
Notifications
You must be signed in to change notification settings - Fork 4
/
c0082.yml
65 lines (55 loc) · 1.84 KB
/
c0082.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
doc_meta: |
folder: dvars
title: datakey as source
head: |
Previously when we render a dvar, we implicitly use all vars from global runtime scope, however sometimes we need to use a specific data object as the data source to render dvar.
In this case, we showcase to render dvar value using data field as source rather the global var name space
sections:
- title: What's the difference
content: |
Please note the datakey tag is used and it is pointing to a variable named student. In this caes the reference of {{.school}} will locate the school from global runtime var: .student.school
Without this tag, the reference of {{.school}} will try to locate a var name school from global runtime
Please also note that the datakey could be a dynamic using var, this gives you a little extra programmingbility for dynamic routing when you combine with logical if tag
- title: Demo
log: yes
notes:
goal:
- showcase the dvar to render value using data field as source rather the global var name space
vars:
student:
name: Tom
gender: Male
school: Sydney Grammar
nsw:
sydney:
sgschool:
student:
name: Tom
gender: Male
school: Sydney Grammar
aaa: aaa
datapointer: student
tasks:
-
name: task
task:
-
func: cmd
dvars:
- name: student_info
value: 'my name is:{{.name}} and I am in {{.school}}'
datakey: student
flags: [vvv]
do:
- name: print
cmd: '{{.student_info}}'
-
func: cmd
dvars:
- name: student_info
value: 'my name is:{{.name}} and I am in {{.school}}'
datakey: '{{.datapointer}}'
flags: [vvv]
do:
- name: print
cmd: '{{.student_info}}'