Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
144 lines (120 sloc) 2.7 KB
description
Some information about the formatting style of YAML

YAML formatting

Introduction

Wump's configuration is written inside of YAML, a "human friendly data serialization" language.
The reason why Wump uses YAML is that it's an easy to read and edit data serialization language (and it's my primary data serialization language)

Examples

Below are some examples on how YAML looks

{% tabs %} {% tab title="Strings" %} {% code-tabs %} {% code-tabs-item title="strings.yaml" %}

# Strings can be written in plain
key: value

# But it's preffered to put them inside of apostrophes
key: 'value'

# To escape an apostrophe, you can simply use 2 of them
key: 'Value''s sheep'

# You can make a multi-line using the > (mt/more than) symbol
key: >
val
ue

# Or you can add a \n after every line using the | (pipe) symbol
key: |
val
ue

# You can also use " (double quotes)
key: "Several lines of text,\n
containing \"double quotes\". Escapes (like \\n) work.\nIn addition,\n
newlines can be esc\\n
aped to prevent them from being converted to a space.\n
\n
Newlines can also be added by leaving a blank line.\n
Leading whitespace on lines is ignored."\n

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %}

{% tab title="Types" %} {% code-tabs %} {% code-tabs-item title="types.yml" %}

# Some of the types that YAML supports:
string: 'hello'
boolean: true
integer: 1
float: 1.1
null: null
object:
    key: 'value'
array:
    - 'entry'

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %}

{% tab title="Objects" %} {% code-tabs %} {% code-tabs-item title="objects.yml" %}

# YAML is sensetive about spaces, here's an example of a parent with 2 childs
parent:
    key: 'value'
    child:
        sibling:
            key: 'value'
    child:
        key: 'value'

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %}

{% tab title="Arrays (1/2)" %} If a file only includes an array, it'll export as an array.

{% code-tabs %} {% code-tabs-item title="array.yml" %}

- 'This file'
- 'Exports as an array'
- true
- 10

{% endcode-tabs-item %} {% endcode-tabs %}

exports as

{% code-tabs %} {% code-tabs-item title="array.js" %}

[
  'This file',
  'Exports as an array'
  true
  10
];

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %}

{% tab title="Arrays (2/2)" %} {% code-tabs %} {% code-tabs-item title="array.yml" %}

# Arrays are written like this

parent:
    # An array with objects
    child: 
        - object: 1
        - object: 2
    child:
        # An array with a number and boolean inside
        array:
            - 1
            - true

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %} {% endtabs %}

You can’t perform that action at this time.