Skip to content

Instantly share code, notes, and snippets.

@devlint
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devlint/2c566559c4a87d93e335 to your computer and use it in GitHub Desktop.
Save devlint/2c566559c4a87d93e335 to your computer and use it in GitHub Desktop.
Sf:include:svg:twig
Il est possible d'inclure un svg directement dans un twig en utilisant {% include %} d'une manière un peu particulière :
2 prérequis :
- le fichier SVG ne sera pas un asset en tant que tel
- le fichier SVG aura une extension `.svg.twig`
## exemple
```twig
<a id="logo" href="{{ path('html_page', {'template': 'pages:01.home%2Fhome.html.twig'}) }}">
{% include "C2isOneTeaBundle:svg:logo_R&C.svg.twig" with {'width': '90'} %}
</a>
```
Le fichier SVG se trouve au même niveau que les `.html.twig` (dans `views`) dans un dossier svg.
C'est en réalité un template twig donc on peut lui passer des paramètres pour le personnaliser
```twig
{% set width = width|default('81') %}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment