YAML 缩进级别有限制吗?
我正在开发一个支持 I18n 的 Ruby on Rails 应用程序。我创建了一个 YAML 文件。但 Rails 报告 YAML 文件中存在语法错误。
我发现如果减少该错误行的缩进级别,就不会再出现错误消息。
YAML 缩进级别(在 Ruby on Rails 中)有任何限制吗?
这是 YAML 块。报告的 fulltime: "Full Time"
行存在语法错误。
en:
jobs:
new:
positiontitle: "Position Title"
country: "Country"
city: "City"
employmenttype: "Employment Type"
fulltime: "Full Time"
parttime: "Part Time"
谢谢大家。 :)
I am developing a Ruby on Rails application with I18n support. I created a YAML file. But Rails report there is syntax error in the YAML file.
I found that if I decrease the level of indentation for that error line, no error message come out again.
Is there any limitation on YAML indentation level (in Ruby on Rails)?
Here is YAML block. The line fulltime: "Full Time"
was reported has syntax error.
en:
jobs:
new:
positiontitle: "Position Title"
country: "Country"
city: "City"
employmenttype: "Employment Type"
fulltime: "Full Time"
parttime: "Part Time"
Thanks everyone. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有限制。错误的可能原因是在缩进 YAML 文件行时使用
TAB
字符而不是空格,而且您的 yaml 文件缩进毫无意义 - 如果您想缩进全职 &兼职 - 那么你必须删除“就业类型”字符串,所以:
there's no limitation. possible cause of error is using a
TAB
characters instead of spaces when indenting YAML file linesalso your yaml file indentation is meaningless - if you want to indent fulltime & parttime - then you have to remove "Employment Type" string, so: