Skip to content

Instantly share code, notes, and snippets.

@Justin2997
Created August 24, 2023 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Justin2997/6026168524c4ad7832a35d9bbec620b1 to your computer and use it in GitHub Desktop.
Save Justin2997/6026168524c4ad7832a35d9bbec620b1 to your computer and use it in GitHub Desktop.
πŸ” 3 Lesser-Known YAML Features You Might Not Be Using!
  1. Complex Data Structures with Anchors and Aliases πŸ”„

    • Define and reuse data structures without duplicating content using anchors (&) and aliases (*).
      default_address: &address
        street: 123 Main St
        city: Anytown
      john:
        <<: *address
        name: John Doe
  2. Merging Key-Value Pairs 🀝

    • Reuse common key-value pairs in multiple places with the merge key (<<).
      default: &default
        color: blue
        size: large
      custom:
        <<: *default
        size: small
  3. Multiline Strings πŸ“

    • Define multiline strings in different ways, perfect for documentation or embedding scripts.
      single_line: "This is a single line string."
      folded_style: >
        This is a multiline
        string where newlines
        will be folded into spaces.
      literal_style: |
        This is a multiline
        string where newlines
        are preserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment