dynamically adding assets
newtonianb opened this issue · comments
newtonianb commented
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?
Emma Fabre commented
function($collection) use ($path)
, see the doc of PHP for more informations.
newtonianb commented
thanks!