From 23ccc0a6a4de1c5b0b42c29a5683cb76d9dcc525 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Sep 2011 22:15:42 -0500 Subject: [PATCH] added better comments to the asset class. --- laravel/asset.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/laravel/asset.php b/laravel/asset.php index f2675e2f..c58ec8a3 100644 --- a/laravel/asset.php +++ b/laravel/asset.php @@ -12,6 +12,14 @@ class Asset { /** * Get an asset container instance. * + * + * // Get the default asset container + * $container = Asset::container(); + * + * // Get a named asset container + * $container = Asset::container('footer'); + * + * * @param string $container * @return Asset_Container */ @@ -27,6 +35,14 @@ public static function container($container = 'default') /** * Magic Method for calling methods on the default Asset container. + * + * + * // Call the "styles" method on the default container + * echo Asset::styles(); + * + * // Call the "add" method on the default container + * Asset::add('jquery', 'js/jquery.js'); + * */ public static function __callStatic($method, $parameters) { @@ -70,6 +86,17 @@ public function __construct($name) * asset being registered (CSS or JavaScript). If you are using a non-standard * extension, you may use the style or script methods to register assets. * + * + * // Add an asset to the container + * Asset::container()->add('jquery', 'js/jquery.js'); + * + * // Add an asset that has dependencies on other assets + * Asset::add('jquery', 'js/jquery.js', 'jquery-ui'); + * + * // Add an asset that should have attributes applied to its tags + * Asset::add('jquery', 'js/jquery.js', null, array('defer')); + * + * * @param string $name * @param string $source * @param array $dependencies @@ -134,6 +161,8 @@ protected function register($type, $name, $source, $dependencies, $attributes) { $dependencies = (array) $dependencies; + $attributes = (array) $attributes; + $this->assets[$type][$name] = compact('source', 'dependencies', 'attributes'); }