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

查看:689
本文介绍了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常见问题解答(感谢))

例如, 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天全站免登陆