2017-10-11 62 views
1

的一部分,我無法弄清楚如何使用一個多行字符串作爲YAML序列的一部分:YAML多行字符串作爲序列

foo: 
    - bar 
    - bar2 
    - > super duper long 
string that I would like 
to have on multiple lines 
    - Another item 

這可能嗎?

回答

2

如果你想使用摺疊標:

foo: 
    - bar 
    - bar2 
    - > 
    super duper long 
    string that I would like 
    to have on multiple lines 
    - Another item 

注意,有可能不會對摺標量的標頭(與>線)的在線內容。

或者,你可以只使用一個普通的標量:

foo: 
    - bar 
    - bar2 
    - super duper long 
    string that I would like 
    to have on multiple lines 
    - Another item 
+0

將普通標折行̶是的,它會,主要區別是,不會有在最後一個換行符? – Nepoxx

+1

是的。如果你想讓摺疊的標量不包含尾隨的換行符,使用'> -'而不是'>'。 – flyx

+0

我想指出,在這種情況下,縮進是非常挑剔的(出於很好的理由)。 – Nepoxx