Last active
August 29, 2015 14:10
-
-
Save devlint/2c566559c4a87d93e335 to your computer and use it in GitHub Desktop.
Sf:include:svg:twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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