📜 ⬆️ ⬇️

Explore view.yml features

A little research on what kind of capabilities the view.yml in symfony supports.

I have long wanted all css and js files to be connected in one place. Due to the fact that I constantly use conditional comments to separate the "godless" browsers, I had to store all the files directly in the template. In case there are several templates, problems started from the category “they added there, they forgot here”. Therefore, it was decided to dig deeper into the depths of symfony, since in the changelog, it was written to 1.2 in Russian and in white: support for conditional comments was added.

What would you like to see?


And, characteristically, all this is. It's just not clear why not a word is said in the documentation for symfony. Apparently, due to the ugliness of the resulting yml.
  <code> stylesheets: [{main.ie.css: {position: 'last', condition: 'lt IE 8', media: 'screen'}}, {frontend.css: {position: 'first', media: 'screen'}}]
 </ code> 


What the heck is that?:)


All this is generated in this PHP array:
  $ stylesheets = array (
   array ('main.ie.css' => array ('position' => 'last', 'condition' => 'lt IE 8', 'media' => 'screen')),
   array ('frontend.css' => array ('position' => 'first', 'media' => 'screen'))
 ); 

')
Why such difficulties, you ask when you can and like this:
  $ stylesheets = array (
   'main.ie.css' => array ('position' => 'last', 'condition' => 'lt IE 8', 'media' => 'screen'),
   'frontend.css' => array ('position' => 'first', 'media' => 'screen')
 ); 


I also believed that you can. This is where the bug of the yaml handler toli, sfViewConfigHandler toli comes up, resulting in a Fatal Error.

In short, while it all smacks of hack, and, apparently, that is why this is all not documented.

But what does all this mean?

Source: https://habr.com/ru/post/70803/


All Articles