skip to content
Alvin Lucillo

Block scalars in YAML

/ 1 min read

💻 Tech

I just learned something new in YAML as I was modifying an API doc. These are two of the special scalar types for string in YAML:

  1. Literal block scalar: uses | to preserve newlines and spaces.
    description: |
      Lorem ipsum dolor sit amet, 
      consectetur adipiscing elit, 
      sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  2. Folded block scalar: uses > to convert newlines into spaces and to preserve paragraph breaks.
    description: >
      Lorem ipsum dolor sit amet, 
      consectetur adipiscing elit, 
      sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.