A unique scenario popped up recently during a project I am building with Aurelia. I needed to cleanly be able to insert SVG images from a folder in my app and display them inline. Duplicating the SVG’s and inlining them was an option, or creating a custom element seemed like a better choice.
What I ended up coming with is the rather simple, but elaborate looking custom element which essentially replaces itself with the contents of an SVG.
To use it, all you need to do is import the
inline-svg class and then in your HTML view:
<inline-svg svg="icons/heart.svg"></inline-svg> you might want to change the path in the above example if you’re not always loading SVG’s from an images folder.