How to define Assetic resources in a Symphony 2 yml or xml configuration file?

Can you define the hellish resource in the configuration file (yml / xml)?

Let's take a jquery example. I would like to have this configuration:

# app/config/config.yml assetic: resources: jquery: latest: "app/Resources/js/jquery-1.6.2.js" 1_6_2: "app/Resources/js/jquery-1.6.2.js" 1_5: "app/Resources/js/jquery-1.5.js" 

And to be able to access this resource from any template in my application, follow these steps:

 {% javascripts 'jquery.latest' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %} 

What is the right way to do this?

One more thing. How to associate a path with the / Resources / js / jquery -1.6.2.js application in a branch template?

 {% javascripts 'app/Resources/js/jquery-1.6.2.js' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %} 

This does not work. Can you do it at all? What resources can I put in the application / Resources and how can I access them in my templates? Where is it documented?

Now symfony 2 really lacks the documentation ...

+6
source share
2 answers

The path to the resource definition in the application / resource folder should be determined using trailing: "../"

 {% javascripts "../app/Resources/js/qtip.jquery.js" "../app/Resources/js/layout.js" "@HomeBundle/Resources/js/*" %} 

Not quite sure how to help you with your first question, but hopefully this can help.

+4
source

I think you want something like strings

 {% javascripts '@NameOfYourBundle/path/from/bundle/root/to/jquery-1.6.2.js' %} 
0
source

Source: https://habr.com/ru/post/894164/


All Articles