Twig: Include external Code from an SVG file

Marten Zander picture Marten Zander · Jul 8, 2016 · Viewed 17.4k times · Source

Is it possible to inlcude code from a svg file directly into a twig template file?

Something like:

{% include 'my.svg' %}

that will result in:

<svg viewbox=".... />

Answer

leSmooth picture leSmooth · Apr 4, 2017

One way of doing this:

{{ source('my.svg') }}

Read more here: https://www.theodo.fr/blog/2017/01/integrating-and-interacting-with-svg-image-files-using-twig/