jasonlewis / basset

A better asset management package for Laravel.
http://jasonlewis.me/code/basset
240 stars 76 forks source link

dynamically adding assets #185

Closed newtonianb closed 11 years ago

newtonianb commented 11 years ago

I'm trying to dynamically add assets from my BaseController given the controller / method, below is a simplified example.

    $path = public_path() . "/assets/css/$controller/$method";

    Basset::collection('custom', function($collection) {
        $collection->directory($path, function($collection) {
            if (file_exists($path . '/style.scss'))
              $collection->stylesheet('style.scss');
            elseif (file_exists($path . '/style.sass')) {
              $collection->stylesheet('style.sass');
            }
        });
    });

However I'm getting Undefined variable: path. How do I pass in that variable to make it accesible?

Anahkiasen commented 11 years ago

function($collection) use ($path), see the doc of PHP for more informations.

newtonianb commented 11 years ago

thanks!