YAML 文件不能包含制表符作为缩进 [英] A YAML file cannot contain tabs as indentation

查看:44
本文介绍了YAML 文件不能包含制表符作为缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次使用 Symfony 2.我在这里要做的就是每当用户点击提交按钮时,他就会转到另一个页面.

This is my first work with Symfony 2. All I am trying to do here is whenever the user clicks on the submit button he will go to another page.

但是我的索引页没有加载.他们说我的路由文件有问题,特别是:

But my index page isn't loading. They are saying there is something wrong with my routing file, specifically:

YAML 文件不能包含制表符作为缩进

A YAML file cannot contain tabs as indentation

我不知道我做错了什么.这是我的路由文件.

I don't know what I have done wrong. Here is my routing file.

community_online_shop_homepage:
    pattern: /
    defaults: { _controller: CommunityOnlineShopBundle:Page:index }
_login:
    pattern: /login
    defaults: { _controller: CommunityOnlineShopBundle:Page:login}

推荐答案

一个 YAML 文件使用空格作为缩进,可以使用 2 或 4 个空格作为缩进,但没有制表符.换句话说,制表符缩进是被禁止的:

A YAML file use spaces as indentation, you can use 2 or 4 spaces for indentation, but no tab. In other words, tab indentation is forbidden:

为什么 YAML 禁止标签页?

标签已被取缔,因为它们被不同的编辑器和工具区别对待.而且由于缩进对于正确解释 YAML 非常重要,这个问题太棘手了,甚至无法尝试.事实上,Python 的 Guido van Rossum 承认在 Python 源代码中允许 TAB 对很多人来说是一个头疼的问题,如果他再次设计 Python,他会禁止它们.

Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them.

(来源:YAML 常见问题(感谢 Destiny Architect 链接))

(source: YAML FAQ (thanks to Destiny Architect for the link))

例如,Symfony 配置文件可以写成 2或 4 个空格作为缩进:

For example, the Symfony configuration file can be written with 2 or 4 spaces as indentation:

doctrine:
    dbal:
        default_connection: default

2 个空格

doctrine:
  dbal:
    default_connection: default

这篇关于YAML 文件不能包含制表符作为缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆