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

Support for asset collections and arrays #85

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

A----
Copy link
Contributor

@A---- A---- commented Mar 8, 2020

This PR adds support for collections (named resources) of assets and arrays.

I did not really get what the previous code was supposed to do when the first parameter was an array. It wouldn't work since the actual call on Grav's asset instance would be addAdd ( https://github.com/getgrav/grav-plugin-shortcode-core/blob/develop/shortcode-core.php#L194 ).

While previously I had to do this:

            $this->shortcode->addAssets('js', 'plugin://a-plugin/assets/a-js.js');
            $this->shortcode->addAssets('css', 'plugin://a-plugin/assets/a-css.css');

With no possibility of overloading those assets. I can now do:

// in a plugin
    public function onAssetsInitialized()
    {
        $assets = $this->grav['assets'];

        $assets->registerCollection('a-collection', [
            'plugin://a-plugin/assets/a-js.js',
            'plugin://a-plugin/assets/a-css.css'
        ]);
    }

// in the shortcode
            $this->shortcode->addAssets('a-collection');

It also fixes the possibility of adding assets by array or string, similar to what Grav's Asset add() method does ( https://learn.getgrav.org/16/api#class-grav-common-assets )

@rhukster rhukster merged commit 85313c5 into getgrav:develop Jul 30, 2020
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