Stolz / Assets

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resource Integrity

almamund opened this issue · comments

Hello,
Is there any way I can easily add resource integrity metadata to link,script tags? Do you've any plan to include this feature in your package?

Regards

commented

There is already a feature for adding metadata (HTML attributes) to the generated HTML tags.

Using ...

Assets::css(['foo' => 'bar', 'dummy']);

... will result in

<link rel="stylesheet" type="text/css" href="css/style.css" foo="bar" dummy="dummy"> 

Or using ...

Assets::js(['foo' => 'bar', 'dummy']);

... will result in

<script type="text/javascript" src="js/effects.js" foo="bar" dummy="dummy">

For adding the resource integrity metadata to links you only need to use:

Assets::css(['integrity' => 'myhash', 'crossorigin' => 'anonymous']);

You have to generate the hash yourself since I don't plan to add such feature.

Hi,

I am using your package as asset manager for my main side project and Im not getting this to work.

I have tried you exact example and I dont get any output like that. In
Assets::css(['foo' => 'bar', 'dummy']);

How did you specify css/style.css? For me it looks like it would apply to all css.

So, how do you apply attributes individually? (I am using the ->add method)

Thanks in advance

commented

@marcmascarell Could you please show us which exact code are you using (both for adding the assets and generating the html tags), which result are you getting (the actual html tags you are getting) and what do you expect to to get?