在yaml的空的领域

mai*_*idi 35 php yaml symfony

我想在我的.yaml字段中保留一个空值,因为在另一个翻译中必须有一些东西但不在这个中.把它留空是打印出值的路径(... title.3).

title:
    1: String
    2: String2
    3:
Run Code Online (Sandbox Code Playgroud)

Ale*_*els 38

如果您想要一个空字符串而不是空值,则可以使用两个单引号.

title:
    1: String
    2: String2
    3: ''
Run Code Online (Sandbox Code Playgroud)


Rob*_*ert 33

你可以使用~null.

你应该阅读YAML的文档,你可以阅读的Symfony YAML格式以及

title:
    1: String
    2: String2
    3: ~
Run Code Online (Sandbox Code Playgroud)

  • 对不起,我不明白.问题是关于yaml的空场.如果您想要获得不同的东西,请编辑您的问题 (6认同)
  • 它仍然为我提供了网站上的路径。我在树枝文件中使用 yml 值: `<h4> {{ '....title.1'|trans }}<sup>7</sup> {{ '...title.2'|trans } }<sup>2</sup> {{ '...title.3'|trans }}` (2认同)

gav*_*koa 7

根据YAML v1.2 规范

10.3.2. 标签解析

Regular expression         Resolved to tag
null | Null | NULL | ~     tag:yaml.org,2002:null
/* Empty */                tag:yaml.org,2002:null
Run Code Online (Sandbox Code Playgroud)

因此,放置null~省略 value 会产生相同的结果tag:yaml.org,2002:null::

parent:
  key1:               # empty so "null", # is a comment!
  key2: ~             # also "null"
  key3: null          # "null" explicitly ))
  key4: !!null "null" # for the funs of "secondary tag handle: !!"
  key5: "null"        # sorry, it is a string or !!str if you like ((
Run Code Online (Sandbox Code Playgroud)