How can I get the URL of the asset directory so it can be used in JavaScript to dynamically load assets?
Background:
In Tapestry 5 the path to assets can change to avoid caching issues. The path depends on the application's version and therefore usually is also different for development, test and production mode.
Injecting assets and getting their path in Java is easy. In .tml
template files it's possible to include the URL using ${asset:classpath:/com/example/myApp/img/test.png}
. In CSS relative paths are working fine. The best solution for JavaScript seems to be to include a script tag in a template and provide a global property that contains the path.
The problem is, how do I get the assets base URL in tapestry?
How can I access this path with JavaScript?