Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Skip assets created by the assetic.asset DI tag in the routing #183

Merged
merged 1 commit into from
Oct 14, 2014
Merged

Skip assets created by the assetic.asset DI tag in the routing #183

merged 1 commit into from
Oct 14, 2014

Conversation

pvolok
Copy link
Contributor

@pvolok pvolok commented Apr 3, 2013

I'm adding assetic tags to the Symfony reference. For the assetic.asset tag, the only use case I can think of is:

services:
    my_asset:
        class: Assetic\Asset\StringAsset
        arguments: [ 'alert("Hey dawg!");' ]
        tags:
            - { name: assetic.asset, alias: my_asset }
{% javascripts '@my_asset' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

But this code produces an error in Symfony\Bundle\AsseticBundle\Routing::load(). It happens because this method tries to get a formula for every asset, while our asset doesn't have a formula. This PR skips assets without formulae.

@stof stof changed the title assetic.asset DI tag Skip assets created by the assetic.asset DI tag in the routing Oct 14, 2014
@stof
Copy link
Member

stof commented Oct 14, 2014

Thanks @pvolok.

@stof stof merged commit 74cf3f7 into symfony:master Oct 14, 2014
stof added a commit that referenced this pull request Oct 14, 2014
…ng (pvolok)

This PR was merged into the 2.4-dev branch.

Discussion
----------

Skip assets created by the assetic.asset DI tag in the routing

I'm adding assetic tags to the [Symfony reference](http://symfony.com/doc/master/reference/dic_tags.html). For the ``assetic.asset`` tag, the only  use case I can think of is:

``` yaml
services:
    my_asset:
        class: Assetic\Asset\StringAsset
        arguments: [ 'alert("Hey dawg!");' ]
        tags:
            - { name: assetic.asset, alias: my_asset }
```

```twig
{% javascripts '@my_asset' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}
```

But this code produces an error in ``Symfony\Bundle\AsseticBundle\Routing::load()``. It happens because this method tries to get a formula for every asset, while our asset doesn't have a formula. This PR skips assets without formulae.

Commits
-------

74cf3f7 Skip formula-less assets in routing
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants