multiline styles

Demos the yaml multiple line usage and shows that the line break could be controlled with different indicator

Block Scalars

Block Style Indicator: The block style indicates how newlines inside the block should behave. If you would like them to be kept as newlines, use the literal style, indicated by a pipe (|). If instead you want them to be replaced by spaces, use the folded style, indicated by a right angle bracket (>). (To get a newline using the folded style, leave a blank line by putting two newlines in. Lines with extra indentation are also not folded.)

Block Chomping Indicator: The chomping indicator controls what should happen with newlines at the end of the string. The default, clip, puts a single newline at the end of the string. To remove all newlines, strip them by putting a minus sign (-) after the style indicator. Both clip and strip ignore how many newlines are actually at the end of the block; to keep them all put a plus sign (+) after the style indicator.

Indentation Indicator: Ordinarily, the number of spaces you’re using to indent a block will be automatically guessed from its first line. You may need a block indentation indicator if the first line of the block starts with extra spaces. In this case, simply put the number of spaces used for indentation (between 1 and 9) at the end of the header.

Demo

source

Main task yaml file
    vars:
      my_interesting_story1: |
        hello
        world
      my_interesting_story2: hello world
      my_interesting_story3: >
        hello world
    
      my_interesting_story4: |-
        hello
        world
      my_interesting_story5: >-
        hello world
      my_interesting_story6: |+
        hello
        world
    
    
    tasks:
    - name: task
      task:
      - func: cmd
        vars:
          isnew: false
        do:
        - name: print
          cmd: "{{if .isnew}}aa{{else}}bb{{end}}"
        - name: print
          desc: literal style, there will be a line break
          cmd: "[{{.my_interesting_story1}}]"
        - name: print
          desc: there will be no a line break
          cmd: "[{{.my_interesting_story2}}]"
        - name: print
          desc: folded style
          cmd: "[{{.my_interesting_story3}}]"
        - name: print
          desc: literal style strip, the end line break is removed
          cmd: "[{{.my_interesting_story4}}]"
        - name: reg
          cmd:
            name: newstory_with_blank_space_front_and_tail
            desc: you can't remove the empty space because it is from the folded feature
              of yaml
            value: >-
              {{if .isnew }} this is a new story {{else}} same old story {{end}}
        - name: reg
          cmd:
            name: newstory_clean
            value: >-
              {{if .isnew}}this is a new story{{else}}same old story{{end}}
      - func: shell
        do:
        - 'echo "[{{.my_interesting_story3}}]"'
        - 'echo [{{.my_interesting_story5}}]'
        - 'echo "[{{.my_interesting_story6}}]"'
        - 'echo "[{{.newstory_with_blank_space_front_and_tail}}]"'
        - 'echo "[{{.newstory_clean}}]"'
    
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 -> c0073
                 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/c0073
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "my_interesting_story3": "hello world\n",
      "my_interesting_story4": "hello\nworld",
      "my_interesting_story5": "hello world",
      "my_interesting_story6": "hello\nworld\n\n\n",
      "my_interesting_story1": "hello\nworld\n",
      "up_runtime_task_layer_number": 0,
      "isnew": false,
      "my_interesting_story2": "hello world"
    })
    
    ~SubStep1: [print:  ]
    bb
    ~SubStep2: [print: literal style, there will be a line break ]
    [hello
    world
    ]
    ~SubStep3: [print: there will be no a line break ]
    [hello world]
    ~SubStep4: [print: folded style ]
    [hello world
    ]
    ~SubStep5: [print: literal style strip, the end line break is removed ]
    [hello
    world]
    ~SubStep6: [reg:  ]
    ~SubStep7: [reg:  ]
    -Step2:
    self: final context exec vars:
    
    (*core.Cache)({
      "newstory_with_blank_space_front_and_tail": " same old story ",
      "my_interesting_story1": "hello\nworld\n",
      "up_runtime_task_layer_number": 0,
      "my_interesting_story6": "hello\nworld\n\n\n",
      "my_interesting_story2": "hello world",
      "my_interesting_story3": "hello world\n",
      "my_interesting_story5": "hello world",
      "newstory_clean": "same old story",
      "my_interesting_story4": "hello\nworld"
    })
    
    cmd( 1):
    echo "[{{.my_interesting_story3}}]"
    
    -
    [hello world
    ]
    
    -
     .. ok
    cmd( 2):
    echo [{{.my_interesting_story5}}]
    
    -
    [hello world]
    
    -
     .. ok
    cmd( 3):
    echo "[{{.my_interesting_story6}}]"
    
    -
    [hello
    world
    
    
    ]
    
    -
     .. ok
    cmd( 4):
    echo "[{{.newstory_with_blank_space_front_and_tail}}]"
    
    -
    [ same old story ]
    
    -
     .. ok
    cmd( 5):
    echo "[{{.newstory_clean}}]"
    
    -
    [same old story]
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level

Other references: