Cheat Sheet速查表
跳转到主要内容

YAML 语法 速查表

本文根据 Devhints / Yaml 翻译。代码示例及版本范围沿用原文。

字典与列表

# comments start with "#"
# dictionary are written like "key: value"
name: Martin D'vloper
languages:
  perl: Elite
  python: Elite
  pascal: Lame

# list items beginn with a "- "
foods:
  - Apple
  - Orange
  - Strawberry
  - Mango

# booleans are lower case
employed: true

多行字符串

# Literal Block Scalar
Multiline: |
  exactly as you see
  will appear these three
  lines of poetry
# Folded Block Scalar
Multiline: <
  this is really a
  single line of text
  despite appearances

继承

parent: &defaults
  a: 2
  b: 3

child:
  <<: *defaults
  b: 4

参考内容

values: &ref
  - These values
  - will be reused below

other_values:
  <<: *ref