2017 © Pedro Peláez
 

library assets

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

image

bubobox/assets

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  • Wednesday, July 23, 2014
  • by Sitebase
  • Repository
  • 3 Watchers
  • 2 Stars
  • 2,575 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

alt text, (*1)

Assets

Assets is a static class that makes it very easy to add javascript or stylesheets to your views., (*2)

Run unit tests

composer install --dev
cd tests
phpunit

Usage

To specify a script or stylesheet to load from your controller your can use following code:, (*3)

use \BuboBox\Assets as Assets;
Assets::js('modules/asset/assets/script.js');
Assets::css('modules/asset/assets/style.css');

Now in your view you can add the script and link tags for the resources using the Assets::render method as follow:, (*4)

echo Assets::render(false, true); // Output only link (stylesheet) tags
echo Assets::render(true, false); // Output only script tags
echo Assets::render(true, true); // Output both link and script tags

For better examples take a look in the examples folder., (*5)

Asset loading order

You can assign a weight order to assets that you add using the second argument in the js and css method. The higher the number the earlier in the source the asset will be loaded., (*6)

Assets::js('modules/asset/assets/script1.js'); // Loaded third
Assets::js('modules/asset/assets/script2.js', 200); // Loaded first
Assets::js('modules/asset/assets/script3.js', 100); // Loaded second

If you don't specify the order weight then the default will be used and that is 0., (*7)

Modifiers

With a modifier callback function you can change the URLs of the assets before it's rendered into HTML. This can be handy if you for example want to load the .debug.js versions of your JavaScript files when your working in your development environment., (*8)

echo Assets::render(true, false, function($url) {
    return str_replace('.min.js', '.js', $url);
});

The Versions

23/07 2014

dev-master

9999999-dev http://github.com/bubobox

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

css frontend asset js include loader stylesheet script

23/07 2014

1.3.0

1.3.0.0 http://github.com/bubobox

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

css frontend asset js include loader stylesheet script

22/07 2014

1.2.0

1.2.0.0 http://github.com/bubobox

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

css frontend asset js include loader stylesheet script

19/03 2014

1.1.0

1.1.0.0 http://github.com/bubobox

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

css frontend asset js include loader stylesheet script

19/03 2014

1.0.0

1.0.0.0 http://github.com/bubobox

Assets is a static class that makes it very easy to add javascript or stylesheets to your views.

  Sources   Download

The Requires

  • php >=5.3.2

 

css frontend asset js include loader stylesheet script