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?
- Support for conditional comments for IE;
- Support for media devices in CSS;
- The ability to change the position of the connected libraries relative to each other.
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?
- main.ie.css - obviously, this is the name of the include file.
- position - The position of the library relative to the rest. May be either first or last. In my opinion, it’s worthwhile not to show off and just indicate the libraries in the order in which they need to be connected.
- condition - The condition for the conditional comment. Obviously, if this key is not specified, conditional comments will not be used. For details on the syntax of conditional comments in MSDN.
- media is a device type. For details on device types, see the CSS documentation.
That's all :)
PS Yes, I will be happy if someone tells me how to highlight the code.
PPS research was conducted on symfony 1.2.8