Assetic & variables doesn't work #182

Closed
shadypierre opened this Issue Apr 2, 2013 · 5 comments

Projects

None yet

5 participants

@shadypierre

Hi,

I tried to follow this article "http://jmsyst.com/blog/asset-variables-in-assetic" to generate & load the translation files depending on the local, but every time I run assetic/dump command, I get the following error

Unable to find file "@MyBundle/Resources/public/js/myFile.{locale}.js"

I have created the file with {locale}, once this file is created, the dump work properly but when i try my application, route generated look like this :

/js/623434d.{locale}_myFile_{locale}.html_1.js

And obviously I get the following error

cannot reference variable name "locale" more than once

I need help please :)

@jglover15

I have also been attempting to follow the article "http://jmsyst.com/blog/asset-variables-in-assetic" and am ending up with what I believe is the same error:

Route pattern "/js/2e9ebd4.{environment}_fos_js_routes.{environment}_1.js" 
cannot reference variable name "environment" more than once.

For more info:

I am using the FOSJsRoutingBundle to expose our Symfony routes to our javascript scripts.
I am trying to generate the correct route based on environment, much like this individual -"FriendsOfSymfony/FOSJsRoutingBundle#57" which in turn pointed me to the above listed article.

I have defined an "environment" variable in assetic as follows:

// app/config/config.yml
assetic:
    variables:
          environment: [prod, dev]

I am attempting to reference the assetic variable in our base.html.twig file as follows:

// app/Resources/view/base.html.twig
{% javascripts "js/fos_js_routes.{environment}.js" vars=["environment"] %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

The following files exist in ../web/js :

fos_js_routes.dev.js
fos_js_routes.prod.js

The php app/console assetic:dump command works (it seems) producing the following output:

...
11:23:23 [file+] /var/www/html/voxrepublic/app/../web/js/2e9ebd4.prod_fos_js_routes.prod_1.js
11:23:23 [file+] /var/www/html/voxrepublic/app/../web/js/2e9ebd4.dev_fos_js_routes.dev_1.js

I get the above error when accessing the site. I have little to go on, what little examples, documentation I have found seem to indicate I am doing this the correct way. I have no idea if I am missing something or if this is a bug. Can anyone point me in the correct direction? Thanks.

@shadypierre

Yes, this is exactly the same problem.

@succinct

I'm also having the same issue, is there anyone looking into this?

@shadypierre shadypierre referenced this issue in kriswallsmith/assetic Apr 25, 2013
Closed

Assetic & variables doesn't work #393

@weaverryan
Symfony member

See symfony/assetic-bundle#136 (I just added a comment on the bottom) for some details that will hopefully help out. Assetic variables are not known well by many people, but hopefully we can figure them out a bit more then document them clearly :).

Thanks!

@stof
Symfony member

Closing as this has been fixed in Assetic

@stof stof closed this Oct 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment