Wojciech Kulik
Wojciech Kulik

Reputation: 8500

Path to web directory and assets in .js files in symfony2

I'm googling and googling and can't find what I need.

How to get path to "web" directory in symfony2 in

In case of .js file I do for now in twig template something like that:

<script type="text/javascript">
var asset_url="{{asset(' ')}}"; 
asset_url = asset_url.substr(0, asset_url.length-1);
</script>
<script href="{{asset('js/script.js')}}" type="text/javascript"></script>

is a better way?

Upvotes: 0

Views: 3114

Answers (1)

Inoryy
Inoryy

Reputation: 8425

If I understood your question correctly, then what you're looking for is $this->getRequest()->getUri() in a controller class.

Take a look at Symfony\Component\HttpFoundation\Request class if it's not, you will most likely find it there.

Upvotes: 1

Related Questions