BudiBadu Logo
Samplebadu

YAML by Example: Directives

1.2

Parser instructions. Version and tag definitions.

Code

%YAML 1.2
%TAG ! tag:clarkevans.com,2002:
---
!shape
  # Use the ! handle for the tag URI
  type: circle
  r: 7
...
# The three dots (...) mark the end of a document

Explanation

Directives appear before the document separator --- and provide instructions to the parser. The %YAML directive specifies which YAML version the file uses. The %TAG directive defines shorthand for long tag URIs.

Multiple documents can exist in one file, each starting with --- and optionally ending with .... Directives only apply to the document that follows them, not the entire file.

Code Breakdown

1
%YAML 1.2 declares the version.
3
--- separates directives from content, or multiple documents.