Skip to content
edmundask edited this page Dec 17, 2011 · 2 revisions

Sometimes it is easier to load assets in groups. You can either define groups in your assets file (assets.yml or assets.php) or assign them manually where needed.

Defining Asset Groups

Assigning assets to groups is pretty straightforward.

jquery:
  type: js
  minify: false
  combine: false
  src: http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js

jquery-ui:
  type: js
  minify: false
  combine: false
  src: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js

# Groups

js-libs:
  type: group
  assets: [jquery, jquery-ui]

Then you can load the assets as a group:

$this->sprinkle->load('js-libs');

Putting Assets Into Groups

When you define and load assets manually, you can still put them into groups.

$scripts = $this->sprinkle->js(
array
(
	'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js',
	'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js'
));

$this->sprinkle->group('custom-scripts', $scripts);

Finally, you can output this specific group by calling:

$this->sprinkle->output('custom-scripts');

To learn more about asset outputting, read Output Assets wiki page.

Clone this wiki locally