symfony Symfony Awkward view.yml js/css positionning syntax

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());
  /* ... */
}

Share the love!

Liked this article? Please consider sharing it on your favorite network, it really helps me a lot!

You can also add your valuable insights by commenting below.