stevebauman/purify

Allow all css and style

Closed this issue ยท 7 comments

Hi @stevebauman , thank you for the work in the package, nice

Steve is there any way to allow all css class="" and style=""?

Appreciate any guidance
good day

Found it, I think, I just added *[style|class] to 'HTML.Allowed'

Seems to be working ๐Ÿ‘

Hi there @nam-co,

Thanks for updating this issue with your resolution! That is the correct way to add those attributes to the allowed HTML.

Marking this as complete ๐Ÿ‘

Thanks @stevebauman , question: the package is so good Im planing on using it on all my projects, is there a way to change the config path? this way I can use a general purify config file that will be included with a general package I use in all my projects, just an idea

I'm so glad you enjoy the package @nam-co! ๐Ÿ˜„

is there a way to change the config path?

You can do this by simply updating the purify.php config to contain a config() reference to another configuration file:

// config/purify.php

return [

    // ...

    'configs' => [
        'default' => config('my-package.purify.config'),
    ],

];

I hope this answers your question!

Steve I tried this, but it comes out as null, but if I dd(config('my-package.purify.text')); it shows the array ok, any ideas?
Sorry about all this questions

'configs' => [
  //default..
  'text' => config('my-package.purify.text'),
  'html' => config('my-package.purify.html')
]

No worries @nam-co! I'm here to help ๐Ÿ™

You're right -- you may have to set the configs at runtime. You can do so in your AppServiceProvider.

Can you give this a shot?

// app/Providers/AppServiceProvider.php

public function boot()
{
    config([
        'purify.configs' => [
            'text' => config('my-package.purify.text'),
            'html' => config('my-package.purify.html'),
        ]
    ]);
}

it worked thanks, since I bet you know a lot more than I do, I need to ask, will this make the load a ms slower? I ask because I do a lot of service provider on my package