github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0021.yml (about) 1 doc_meta: | 2 folder: vars 3 title: use golang template 4 head: | 5 Demo to show using template 6 7 Please note that you can not reference to a sub element if it is in string literal, such as example of .info.school 8 9 sections: 10 - title: Demo 11 log: yes 12 13 notes: 14 goal: 15 - to show using template 16 17 tasks: 18 19 - name: task 20 task: 21 - 22 func: shell 23 vars: 24 student: Tom 25 gender: Male 26 school: Sydney Grammar 27 info: | 28 student: Tom 29 gender: Male 30 school: Sydney Grammar 31 do: 32 - | 33 echo """my student: {{.student}} 34 student's gender: {{.gender}} 35 school's name: {{.school}}""" 36 - | 37 {{$details := .}} 38 echo """my student: {{$details.student}} 39 student's gender: {{$details.gender}} 40 school's name: {{$details.school}}""" 41 - | 42 {{$a := .student}} 43 {{$b := .gender}} 44 {{$c := .school}} 45 echo """my student: {{$a}} 46 student's gender: {{$b}} 47 school's name: {{$c}}""" 48 - | 49 echo """my school: {{.info.school}}""" 50 - | 51 echo """my student: {{.info}}""" 52 flags: 53 - ignoreError