Reputation: 69
i working on an AngularJS/Symfony project and I cant figure out how to define correctly the path of a twig template in my js.
The path to: -the original JS -the template -the JS path with assetic
...
+-src/
| +-MyCompany/
| +-MyBundle/
| +-Resources/
| +-public/
| +-js/
| +-directive/
| +-my_file.js
| +-view/
| +-template/
| my_template.html.twig
+-web/
| bundles/
| +-MyBundle/
| +-js/
| +-my_fil.js
...
My js code:
return {
templateUrl: '?'
}
So, is there a way to include a path from a bundle into an asset file? (I tried the @bundle/ notation, but didnt work). Or, when I include the js in my html, to use the js of the bundle and not the one of the asset?
Thanks
Upvotes: 0
Views: 307
Reputation: 3085
That would be
{% javascripts filter='?uglifyjs2'
'@AppBundle/Resources/assets/js/your-file.js'
'@AppBundle/Resources/assets/js/your-second-file.js'
'@AppBundle/Resources/assets/js/admin-*.js'
%}
<script type="text/javascript" src="{{ asset(asset_url) }}"></script>
{% endjavascripts %}
The filter allows you to apply, for instance, UglifyJS
in this example. The path points to src/AppBundle/Resouces/assets/js/
and will combine the two files. It's even possible to use wildcards.
Upvotes: 1