Stolz / Assets

An ultra-simple-to-use assets management library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

<style id="myid"

donny26utama opened this issue · comments

how i can add some attribute like id?

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