<h1>
Publications
{embeddedSvg 'icons/help.svg'}
</h1>
Result HTML code will look like:
<h1>
Publications
<svg xmlns="..." >
... content of help.svg file ...
</svg>
</h1>
This is a single purpose helper library with a macro definition for Latte, the PHP templating engine. It loads SVG source file and embed it into HTML code in compile time.
This allows to stylize SVG by CSS. It isn't easy with SVG linked as an image <img src="icons/help.svg">
.
Require library:
composer require milo/embedded-svg
Register extension in your config.neon
and configure it:
extensions:
embeddedSvg: Milo\EmbeddedSvg\Extension
embeddedSvg:
baseDir: %wwwDir%/img
Because embeddedSvg
is a macro, it is compiled into PHP only once and then is cached.
So, when you change the macro configuration, probably in NEON, you have to purge Latte cache.