I’m using inline SVGs most on my current project and most of the time I have to add a CSS class on the SVG tag because I’m using Tailwindcss to style the app. This works for me but obviously, my code is now full of gibberish SVG codes.
I’ve watched a video where the coder is using Laravel + Blade and he could easily include his SVGs like this
Blade is the template language for Laraval. You can use it with Kirby but for that you need a plugin, and to re-write all the temples and snippets.
You could put svg helper in a snippet with a DIV round it and the class attribute on it, and pass the class through as a parameter, as well as the URL.
This would be the right solution for my needs. And I think it’s still possible to make it cleaner by making it as a snippet or something better on which I will just have to pass the filename, right?
As always, the fastest and most helpful person, thank you @texnixe
Depends where you want to store the SVG files as well, since the example above expects them to belong to the current page. You might need to make two snippets, one for pulling from the assets directory (useful for things like site footers & headers), and one specific page files.
Sorry to reopen the thread. I did try the solution and it works great. One issue I have though is I cannot add multiple CSS classes. It only accepts a single $class value.