github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0073.yml (about) 1 doc_meta: | 2 folder: syntax 3 title: multiline styles 4 head: | 5 Demos the yaml multiple line usage and shows that the line break could be controlled with different indicator 6 7 sections: 8 - title: Block Scalars 9 content: | 10 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.) 11 12 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. 13 14 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. 15 16 - title: Demo 17 log: yes 18 19 related: 20 refs: 21 - title: Block Scalars 22 link: https://yaml-multiline.info/ 23 24 vars: 25 my_interesting_story1: | 26 hello 27 world 28 29 my_interesting_story2: hello 30 world 31 32 my_interesting_story3: > 33 hello 34 world 35 36 my_interesting_story4: |- 37 hello 38 world 39 40 my_interesting_story5: >- 41 hello 42 world 43 44 my_interesting_story6: |+ 45 hello 46 world 47 48 49 tasks: 50 51 - name: task 52 task: 53 - func: cmd 54 vars: 55 isnew: false 56 do: 57 - 58 name: print 59 cmd: "{{if .isnew}}aa{{else}}bb{{end}}" 60 61 - 62 name: print 63 desc: literal style, there will be a line break 64 cmd: "[{{.my_interesting_story1}}]" 65 66 - 67 name: print 68 desc: there will be no a line break 69 cmd: "[{{.my_interesting_story2}}]" 70 71 - 72 name: print 73 desc: folded style 74 cmd: "[{{.my_interesting_story3}}]" 75 76 - 77 name: print 78 desc: literal style strip, the end line break is removed 79 cmd: "[{{.my_interesting_story4}}]" 80 81 - name: reg 82 cmd: 83 name: newstory_with_blank_space_front_and_tail 84 desc: you can't remove the empty space because it is from the folded feature of yaml 85 value: >- 86 {{if .isnew }} 87 this is a new story 88 {{else}} 89 same old story 90 {{end}} 91 92 - name: reg 93 cmd: 94 name: newstory_clean 95 value: >- 96 {{if .isnew}}this is a new story{{else}}same old story{{end}} 97 98 99 - func: shell 100 do: 101 - 'echo "[{{.my_interesting_story3}}]"' 102 - 'echo [{{.my_interesting_story5}}]' 103 - 'echo "[{{.my_interesting_story6}}]"' 104 - 'echo "[{{.newstory_with_blank_space_front_and_tail}}]"' 105 - 'echo "[{{.newstory_clean}}]"'