0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.