artack / svg-inline-bundle
Symfony bundle providing a Twig function to inline SVG files into HTML
Package info
github.com/artack/svg-inline-bundle
Type:symfony-bundle
pkg:composer/artack/svg-inline-bundle
Requires
- php: ^8.1
- symfony/config: ^6.1|^7|^8
- symfony/dependency-injection: ^6.1|^7|^8
- symfony/http-kernel: ^6.1|^7|^8
- symfony/string: ^6.1|^7|^8
- twig/twig: ^3
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Twig function to embed svg files as inline svg code into your html code.
Developed by artack in Zurich, Switzerland.
Features
- Provides twig function to embed svg files as inline svg code into your html code
- Compatible with PHP >= 8.1.
- Compatible with Symfony >= 6.1 (including 7 and 8).
Installation
You can install this bundle through Composer:
$ composer require artack/svg-inline-bundle
Configuration
Register the bundle in your config/bundles.php file.
return [ ... Artack\SvgInlineBundle\SvgInlineBundle::class => ['all' => true], ... ];
Create the configuration file in your config/packages/artack_svg_inline.yaml to define the base path for the svg files.
svg_inline: path: "%kernel.project_dir%/assets/ci/icon"
Usage
Load a svg file as inline svg code into your html code:
# some/template.html.twig
{{ svg_inline('twitter.svg') }}
If you want to add classes to the svg tag you can use the class parameter:
# some/template.html.twig
{{ svg_inline('twitter.svg', class: 'add as many classes as you want') }}