github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0110.yml (about)

     1  doc_meta: |
     2    folder: flow-controll
     3    title: loopitem in callee's dvar
     4    head: |
     5      This showcases the loopitem/loopindex will be available in the dvars scope for reference
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11  notes:
    12    - to test out the internal var loopitem could be used in dvar reference
    13  
    14  tasks:
    15    -
    16      name: task
    17      task:
    18  
    19        -
    20          func: call
    21          do:
    22            - subtask1
    23          loop:
    24            - tom
    25            - jerry
    26            - emily
    27  
    28    -
    29      name: subtask1
    30      task:
    31        -
    32          func: cmd
    33          do:
    34            - name: print
    35              cmd: '{{.loopindex1}}:{{.loopitem}}'
    36  
    37        -
    38          func: cmd
    39          do:
    40            -
    41              name: assert
    42              cmd:
    43                - '{{eq .loopitem "tom"}}'
    44          if: '{{eq .loopindex1 1}}'
    45  
    46        -
    47          func: cmd
    48          vars:
    49            person: '{{.loopitem}}'
    50          do:
    51            - name: print
    52              cmd: '{{.person}}'
    53  
    54        -
    55          func: cmd
    56          dvars:
    57            - name: theone
    58              value: '{{.loopitem}}'
    59          do:
    60            - name: print
    61              cmd: '{{.theone}}'