Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Timber embed SVG Plugin for WordPress
* embed SVG
* Example: <span>{{ "logo"|svg }}</span>
* @param \Twig\Environment $twig The Twig environment.
* @return \Twig\Environment
function twig_svg_embed($twig)
new Timber\Twig_Filter("svg", function ($name) {
return file_get_contents(
"wp-content/themes/{themename}/icon/" .
$name .
return $twig;
add_filter("timber/twig", "twig_svg_embed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment