【发布时间】:2015-08-04 04:56:04
【问题描述】:
我有一个用长语法编写的 YAML 文件
children:
-
type: section
subtype: false
title: Top-wrapper
attributes: { }
children:
-
type: section
subtype: false
title: Second-wrapper
attributes: { }
children:
-
type: section
subtype: false
title: Header
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: section
subtype: false
title: Navigation
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: section
subtype: false
title: Showcase
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: section
subtype: false
title: Feature
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: section
subtype: false
title: Main-content
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 20
children:
-
type: section
subtype: false
title: Sidebar-left
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: position
subtype: false
title: Sidebar-left
attributes:
enabled: 1
key: sidebar-left
title: Sidebar-left
children: { }
-
type: block
subtype: false
title: Untitled
attributes:
size: 60
children:
-
type: section
subtype: false
title: Main
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: pagecontent
subtype: false
title: Pagecontent
attributes:
enabled: 1
children: { }
-
type: block
subtype: false
title: Untitled
attributes:
size: 20
children:
-
type: section
subtype: false
title: Sidebar-right
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: position
subtype: false
title: Sidebar-right
attributes:
enabled: 1
key: sidebar-right
title: Sidebar-right
children: { }
-
type: section
subtype: false
title: Subfeature
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: section
subtype: false
title: Footer
attributes: { }
children:
-
type: container
subtype: false
title: Untitled
attributes: { }
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children:
-
type: block
subtype: false
title: Untitled
attributes:
size: 100
children:
-
type: spacer
subtype: false
title: Spacer
attributes:
enabled: 1
children: { }
-
type: offcanvas
subtype: false
title: Offcanvas
attributes:
name: 'Offcanvas Section'
children: { }
-
type: atoms
subtype: false
title: Atoms
attributes:
name: 'Atoms Section'
children:
-
type: grid
subtype: false
title: Untitled
attributes: { }
children: { }
我想把它转换成类似这样的简写语法
layout:
1:
- top-wrapper 100:
header:
container:
- spacer
navigation:
container:
- [particle-logo 20, particle-menu 80]
showcase:
container:
- spacer
feature:
container:
- spacer
main:
container:
- system-messages
- pagecontent
footer:
container:
- spacer
debug:
container:
- spacer
offcanvas:
- particle-mobile-menu
我知道 YAML 对使用简写语法有一定的规定,我该如何使用它?
【问题讨论】: