-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow newlines and trailing comma in inline tables (#904)
- Loading branch information
Showing
3 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -797,23 +797,32 @@ Inline Table | |
------------ | ||
|
||
Inline tables provide a more compact syntax for expressing tables. They are | ||
especially useful for grouped data that can otherwise quickly become verbose. | ||
especially useful for grouped nested data that can otherwise quickly become | ||
verbose. | ||
|
||
Inline tables are fully defined within curly braces: `{` and `}`. Within the | ||
braces, zero or more comma-separated key/value pairs may appear. Key/value pairs | ||
take the same form as key/value pairs in standard tables. All value types are | ||
allowed, including inline tables. | ||
|
||
Inline tables are intended to appear on a single line. A terminating comma (also | ||
called trailing comma) is not permitted after the last key/value pair in an | ||
inline table. No newlines are allowed between the curly braces unless they are | ||
valid within a value. Even so, it is strongly discouraged to break an inline | ||
table onto multiples lines. If you find yourself gripped with this desire, it | ||
means you should be using standard tables. | ||
Inline tables can have multiple key/value pairs on the same line, or they can be | ||
put on different lines. A terminating comma (also called trailing comma) is | ||
permitted after the last key/value pair. | ||
|
||
```toml | ||
name = { first = "Tom", last = "Preston-Werner" } | ||
point = { x = 1, y = 2 } | ||
point = {x=1, y=2} | ||
animal = { type.name = "pug" } | ||
contact = { | ||
personal = { | ||
name = "Donald Duck", | ||
email = "[email protected]", | ||
}, | ||
work = { | ||
name = "Coin cleaner", | ||
email = "[email protected]", | ||
}, | ||
} | ||
``` | ||
|
||
The inline tables above are identical to the following standard table | ||
|
@@ -830,6 +839,14 @@ y = 2 | |
|
||
[animal] | ||
type.name = "pug" | ||
|
||
[contact.personal] | ||
name = "Donald Duck" | ||
email = "[email protected]" | ||
|
||
[contact.work] | ||
name = "Coin cleaner" | ||
email = "[email protected]" | ||
``` | ||
|
||
Inline tables are fully self-contained and define all keys and sub-tables within | ||
|