I'm unsure how I can get something equivalent to: path('public') to work in a Javascript file?
I basically just need the path to the public folder for displaying some images from my JS file.
You could opt to create a variable in JavaScripts global namespace in the head of your document and use PHP to echo out the public path.
<head>
<script>
var public_path = '{{ path('public') }}';
</script>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With