Skip to content

Plemi/Twig-extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Plemi Twig extensions

Base64 encoding for images

Basic Twig function to allow base64 images encoding following latest RFC.

Usage in the real world

First of all, add this to your composer.json.

{
    "require": {
        "plemi/twig-extensions": "dev-master"
    }
}

Symfony2

<service id="plemi.twig.base64_extension" class="Plemi\Twig\Extensions\Base64Extension" public="false">
    <tag name="twig.extension" />
</service>

Silex

<?php

// After registering Twig Silex Provider
$app['twig']->addExtension(new \Plemi\Twig\Extensions\Base64Extension());

Then in your twig templates, just call the function with the file path as an argument.

{{ image64('/images/logo.jpg') }}

About

Plemi additional functions and filters for Twig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages