Awkward view.yml js/css positionning syntax
• By Romain Dorgueil
Outdated Content
This article is preserved for historical purposes and does not reflect current practices or technologies.
Short post today about advanced view.yml configuration (in symfony 1.0, and
1.1) for assets.
You can give additional options to javascripts: and stylesheets: sections,
but the sin equa non condition is to know about the yet very un-documented
view.yml assets syntax.
So here it is:
javascripts: [ jquery: { position: first } ]
stylesheets: [ mycss: { position: last, media: screen } ]
I don’t know if there are others options like thoose available, but taken the
‘position’ attribute apart, which is extracted to become the $position method
argument of sfWebResponse::addJavascript() and
sfWebResponse::addStylesheet(), any other option is passed in the $options
array.
Methods prototypes below:
<?php
class sfWebResponse ...
{
/* ... */
public function addJavascript($js, $position = '', $options = array());
public function addStylesheet($css, $position = '', $options = array());
/* ... */
}