- 🇨🇦Canada lolcode
I think that there is a documentation or missing API issue. I can use namespaces to include other templates.
However, I can't seem to find a Twig function to resolve a namespaced path so that I can print an image link.
For example in my base theme I want to do this:<img src="@mytheme/library/01-atoms/file-type-icons/images/{{ extension }}.png" alt="{{ extension }} file format" class="{{ classes|join(' ') }}">
- 🇦🇹Austria roromedia Linz
I want to point out that {{ source() }} is not a good work-around as it has performance implications - each assets included with source() is not cached by the browser but will be loaded every time fresh on every page load (huge overhead if you are using it eg. for SVG-icons which you reuse multiple times on a page).
So the only way to get this working would be a solution with an img-tag to get browser caching.In general there should be a reliable TWIG-variable in core which gives me the actual theme path of the file I am in.
- 🇪🇨Ecuador jwilson3
each asset included with source() is not cached by the browser but will be loaded every time fresh on every page load
Sure, but this point is totally unrelated to the issue here. Each developer needs to consider the tradeoffs of using inline SVGs, SVG Sprites, or IMG tags pointing to SVG files on the server. If you've got a proper CDN or other caching techniques in place, then inline SVGs are cached in the browser, alongside the entire HTML of the page, or also perhaps in Drupal Dynamic Cache, or Page Cache, as the case may be.