Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A YAML file cannot contain tabs as indentation

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:

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} 
like image 203
odbhut.shei.chhele Avatar asked Nov 14 '13 11:11

odbhut.shei.chhele


People also ask

Are tabs allowed in YAML?

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: Why does YAML forbid tabs? Tabs have been outlawed since they are treated differently by different editors and tools.

Does YAML support tab characters?

Tabs ARE allowed in YAML, but only where indentation does not apply. According to YAML 1.2 Section 5.5: YAML recognizes two white space characters: space and tab.

What does indentation mean in YAML?

In YAML block styles, structure is determined by indentation. In general, indentation is defined as a zero or more space characters at the start of a line. To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently.

How do I delete a tab from YAML?

Go to Settings >> Preferences and choose Tab Settings. Scroll down in the “Tab Settings” list to “yaml”. Uncheck the “use default value” and choose “replace by space”.


2 Answers

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:

Why does YAML forbid tabs?

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.

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

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

4 spaces

doctrine:     dbal:         default_connection: default 

2 spaces

doctrine:   dbal:     default_connection: default 
like image 163
A.L Avatar answered Sep 24 '22 05:09

A.L


IF you are using EditorConfig make sure to add this to your .editorconfig file

[*.yml] indent_style = space indent_size = 4 

you can change indent_size to 2, depends on your preferences

like image 43
chebaby Avatar answered Sep 21 '22 05:09

chebaby