Is it possible to inlcude code from a svg file directly into a twig template file?
Something like:
{% include \'my.svg\' %}
that wi
For me, it worked:
{% include '/images/my.svg' %}
Just a quick update if you are using Drupal 8 because the code in the previous answer didn't work for me. This is how I did it:
function theme_preprocess_page(&$variables) {
$svg = file_get_contents(drupal_get_path('theme', 'theme_name') . '/images/my.svg');
$variables['some_svg'] = $svg;
}
And in the twig file, output using raw
filter, or else it will escape the SVG markup:
{{ some_svg|raw }}