YAML 缩进级别有限制吗?

发布于 2024-09-08 08:10:00 字数 520 浏览 4 评论 0原文

我正在开发一个支持 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2024-09-15 08:10:00

没有限制。错误的可能原因是在缩进 YAML 文件行时使用 TAB 字符而不是空格,

而且您的 yaml 文件缩进毫无意义 - 如果您想缩进全职 &兼职 - 那么你必须删除“就业类型”字符串,所以:

en:
  jobs:
    new:
      positiontitle:    "Position Title"
      country:          "Country"
      city:             "City"
      employmenttype:
        fulltime:         "Full Time"
        parttime:         "Part Time"

there's no limitation. possible cause of error is using a TAB characters instead of spaces when indenting YAML file lines

also your yaml file indentation is meaningless - if you want to indent fulltime & parttime - then you have to remove "Employment Type" string, so:

en:
  jobs:
    new:
      positiontitle:    "Position Title"
      country:          "Country"
      city:             "City"
      employmenttype:
        fulltime:         "Full Time"
        parttime:         "Part Time"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文