2017 © Pedro Peláez
 

library svg-twig-extension

Add inline svg with Twig

image

manuelodelain/svg-twig-extension

Add inline svg with Twig

  • Monday, November 13, 2017
  • by manuelodelain
  • Repository
  • 2 Watchers
  • 5 Stars
  • 256 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 37 % Grown

The README.md

Svg Twig extension

Add inline svg with Twig version 2 or 3, (*1)

Installation

With Composer: composer require manuelodelain/svg-twig-extension, (*2)

Usage

use manuelodelain\Twig\Extension\SvgExtension;
use Twig\Environment;

$twig = new Environment(...);

$twig->addExtension(new SvgExtension());
{{ svg('img.svg') }}

Will output your svg file inline., (*3)

You can omit the extension, (*4)

{{ svg('img') }}

You can add a global base path:, (*5)

new SvgExtension('assets/img')

Options

Add or replace attributes with the attr property:, (*6)

{{ svg('img.svg', {attr: {class: 'inline-svg', id: 'marker-1'}}) }}

Add CSS classes:, (*7)

{{ svg('img.svg', {classes: 'add-classname another-classname'}) }}

The Versions

13/11 2017

dev-master

9999999-dev

Add inline svg with Twig

  Sources   Download

The Development Requires

13/11 2017

0.1

0.1.0.0

Add inline svg with Twig

  Sources   Download

The Development Requires