cedricziel / twig-loader-flysystem
Flysystem loader for the twig templating language
Fund package maintenance!
cedricziel
Requires
- php: ~5.5|~7.0
- league/flysystem: ^1.0
- twig/twig: ^1.24
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-10-28 10:57:53 UTC
README
Flysystem loader for the Twig templating engine.
Installation
The library is installable through composer:
composer require cedricziel/twig-loader-flysystem
Usage
Adapted from the official Twig documentation
$localAdapter = new League\Flysystem\Adapter\Local(__DIR__); $filesystem = League\Flysystem\Filesystem($localAdapter); $loader = new CedricZiel\TwigLoaderFlysystem\FlysystemLoader($filesystem); $twig = new \Twig_Environment($loader); $template = $twig->loadTemplate('index.html.twig'); $content = $template->render(array('the' => 'variables', 'go' => 'here'));
The loader also supports using a subdirectory on the associated flysystem as permanent prefix:
$localAdapter = new League\Flysystem\Adapter\Local(__DIR__); $filesystem = League\Flysystem\Filesystem($localAdapter); $loader = new CedricZiel\TwigLoaderFlysystem\FlysystemLoader($filesystem, 'templates'); $twig = new \Twig_Environment($loader); // this will load 'templates/index.html.twig' from the current flysystem filesystem $template = $twig->loadTemplate('index.html.twig'); $content = $template->render(array('the' => 'variables', 'go' => 'here'));
License
MIT