Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add attributes to blade directives #56

Merged

Conversation

juliomotol
Copy link
Contributor

This PR aims to improve the current blade directives available with the following notable changes:

  • Can now pass multiple parameters to the @mixSri and @assetSri blade directives.
    • Before, @mixSri('app.css', true) doesn't work since the directive because when extending the directive, it only allows 1 parameter.
  • A third parameter has been added to support other attributes for script and link tags attributes.
    • The new signature is @assetSri(string $path, bool $useCredentials, string $attributes).
  • The blade directive logic has been moved to the Sri class.
    • Did this to allow multiple variables to pass through in the blade directives.

This PR also adds tests for the blade directives which there wasn't any before.

@juliomotol juliomotol force-pushed the feature/add-attributes-to-blade-directives branch from 4ba6466 to cea94e0 Compare July 8, 2020 09:38
@juliomotol
Copy link
Contributor Author

I just saw PR #37 and I think this is a cleaner solution since $attributes is more general than $execute but the idea is pretty much the same.

@Elhebert
Copy link
Owner

Elhebert commented Jul 8, 2020

Nice PR, I'll have a deeper look later this week.

I think that I might remove the Blade directive soon to use Blade component that will provide a far better DX 🤔

@juliomotol
Copy link
Contributor Author

Interesting! On v3 maybe?

I also noticed that you're setting an alias for Sri::class with sri in lowercase. Normally, aliases are pointed to the facade and is CamelCased.

$this->app->alias(Sri::class, 'sri');

$this->app->alias(SriFacade::class, 'Sri');

@Elhebert
Copy link
Owner

Elhebert commented Jul 9, 2020

I think I will first do a new minor with the components, then remove them in a major version (so yeah 3.0).
It's a bit hard for me to work on this package as I'm currently not working with Laravel anymore. But I do intent to do a full rewrite for a v3 at some point.

For the Alias I think we can remove the one in the service provider because I set one in the composer.json:

https://github.com/Elhebert/laravel-sri/blob/master/composer.json#L42-L44

@juliomotol
Copy link
Contributor Author

I see. I also have a few concerns that could be implemented in v3 if you are open for an RFC.

@Elhebert Elhebert merged commit 1e5e121 into Elhebert:master Jul 13, 2020
@Elhebert
Copy link
Owner

Elhebert commented Jul 13, 2020

I'll create an issue for v3 improvements.

See #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants