Overview

January 29, 2018 ยท View on GitHub

Build Status

Overview

  • A Twig extension for embedding inline QR codes in Twig templates.
  • The standard filter output is a DataURL string of the processed text.
composer require priotas/twig-qrcode-extension
<!-- index.html.twig -->
<!DOCTYPE html>
<html>
    <body>

        <img src="{{ 'http://kewl.example.com' | qrcode(size=200) }}" />
    
    </body>
</html>

use Priotas\Twig\Extension\QrCode;

$loader = new \Twig_Loader_Filesystem(__DIR__);
$twig = new \Twig_Environment($loader);
$twig->addExtension(new QrCode());

echo $twig->render('index.html.twig');

Available filter options

OptionTypeDefaultDescription
typestringpngThe image type. Available types are png,eps,svg
labelstringA label for the QR code
sizeinteger200The size of the QR code
versionintegerautoThe version of the QR code. Range 1-40
svgstringdata_uriHow a SVG should be rendered. data_uri is a data:svg+xml blob. inline is an inline svg tag

Dependencies