use golang template

Demo to show using template

Please note that you can not reference to a sub element if it is in string literal, such as example of .info.school

Demo

source

Main task yaml file
    tasks:
    - name: task
      task:
      - func: shell
        vars:
          student: Tom
          gender: Male
          school: Sydney Grammar
          info: |
            student: Tom
             gender: Male
             school: Sydney Grammar
        do:
        - |
          echo """my student: {{.student}}
          student's gender: {{.gender}}
           school's name: {{.school}}"""
        - |
          {{$details := .}}
          echo """my student: {{$details.student}}
          student's gender: {{$details.gender}}
           school's name: {{$details.school}}"""
        - |
          {{$a := .student}}
          {{$b := .gender}}
          {{$c := .school}}
          echo """my student: {{$a}}
          student's gender: {{$b}}
           school's name: {{$c}}"""
        - |
          echo """my school: {{.info.school}}"""
        - |
          echo """my student: {{.info}}"""
        flags:
        - ignoreError
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0021
                 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/c0021
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "student": "Tom",
      "gender": "Male",
      "school": "Sydney Grammar",
      "up_runtime_task_layer_number": 0,
      "info": "student: Tom\n gender: Male\n school: Sydney Grammar\n"
    })
    
    cmd( 1):
    echo """my student: {{.student}}
    student's gender: {{.gender}}
     school's name: {{.school}}"""
    
    
    -
    my student: Tom
    student's gender: Male
     school's name: Sydney Grammar
    
    -
     .. ok
    cmd( 2):
    {{$details := .}}
    echo """my student: {{$details.student}}
    student's gender: {{$details.gender}}
     school's name: {{$details.school}}"""
    
    
    -
    my student: Tom
    student's gender: Male
     school's name: Sydney Grammar
    
    -
     .. ok
    cmd( 3):
    {{$a := .student}}
    {{$b := .gender}}
    {{$c := .school}}
    echo """my student: {{$a}}
    student's gender: {{$b}}
     school's name: {{$c}}"""
    
    
    -
    my student: Tom
    student's gender: Male
     school's name: Sydney Grammar
    
    -
     .. ok
    cmd( 4):
    echo """my school: {{.info.school}}"""
    
    
          template rendering -> template: .:1:26: executing "." at <.info.school>: can't evaluate field school in type interface {}
    WARN:
        1:echo """my school: {{.info.school}}"""
        2:
    
    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
    
          template rendering -> template: .:1:26: executing "." at <.info.school>: can't evaluate field school in type interface {}
    WARN:
        1:echo """my school: {{.info.school}}"""
        2:
    
    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
    
    -
    /bin/sh: syntax error: unterminated quoted string
    
    -
     .. failed(suppressed if it is not the last step)
    cmd( 5):
    echo """my student: {{.info}}"""
    
    
    -
    my student: student: Tom
     gender: Male
     school: Sydney Grammar
    
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level