Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedricziel/twig-loader-flysystem
Flysystem loader for the twig templating engine
https://github.com/cedricziel/twig-loader-flysystem
flysystem twig
Last synced: 13 days ago
JSON representation
Flysystem loader for the twig templating engine
- Host: GitHub
- URL: https://github.com/cedricziel/twig-loader-flysystem
- Owner: cedricziel
- License: mit
- Created: 2016-07-06T05:51:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-27T12:43:55.000Z (over 7 years ago)
- Last Synced: 2024-10-04T19:16:33.009Z (about 1 month ago)
- Topics: flysystem, twig
- Language: PHP
- Size: 16.6 KB
- Stars: 6
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Twig loader for flysystem filesystems
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/cedricziel/twig-loader-flysystem/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/cedricziel/twig-loader-flysystem/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/cedricziel/twig-loader-flysystem/badges/build.png?b=master)](https://scrutinizer-ci.com/g/cedricziel/twig-loader-flysystem/build-status/master)
[Flysystem](http://flysystem.thephpleague.com/) loader for the [Twig](http://twig.sensiolabs.org/) templating engine.
## Installation
The library is installable through composer:
```bash
composer require cedricziel/twig-loader-flysystem
```## Usage
Adapted from the [official Twig documentation](http://twig.sensiolabs.org/doc/api.html#basics)
```php
$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:```php
$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