主にdotinstall YAML入門のまとめ
実際の使用例はこちら
[red,blue,green]
- red
- blue
- green
- red
- blue
- # ここは空白
- orange
- pink
- green
{site_name : site name, description: site description}
# :で位置を揃えると美しい
site_name : site name
description: site description
# 入れ子
meta:
title: page title
description: description
keywords: [keyword01, keyword02, keyword03]
- name: sato
age : 20
- name: suzuki
age : 25
# インライン
- { name: sato, age: 20 }
- { name: suzuki, age: 25 }
|-
this
is
a
pen.
|+
this
is
a
pen.
- &taguchi
name: taguchi
score: 80
- &fkoji
name: fkoji
score: 90
friends:
- *taguchi
- name: dotinstall
score: 100
friends:
- *taguchi
- *fkoji
defaults: &defaults
user: dbuser
password: dbpassword
database: myapp
development:
<<: *defaults # マージ
database: myapp_dev
test:
<<: *defaults
database: myapp_test
production:
<<: *defaults
database: myapp_prod
.to_yaml
メソッドを使う (ruby)
users = [
{'name' => 'sato', 'age' => 20},
{'name' => 'suzuki', 'age' => 30},
]
puts users.to_yaml
- name: sato
age: 20
- name: suzuki
age: 30