<style id="myid"
donny26utama opened this issue · comments
Donny Akhmad Septa Utama commented
how i can add some attribute like id?
Javi commented
Hi @donny26utama .
The css()
function supports passing an array of attributes to customize the rendered tag:
Assets::add('style.css')->css(['foo' => 'bar', 'async']);
will result in
<link ... foo="bar" async="async"/>
For your case you can use:
Assets::css(['id' => 'myid']);
If you need more control you can pass a closure that will receive an array with the assets and it should return the tags:
Assets::css(function (array $assets) use ($id) {
$output = '';
foreach($assets as $k => $a)
$output .= '<style src="' . $a . '" id="' . $id . $k . '"></style>';
return $output
});
More info in the API docs