rych / silex-plates-provider
Provides Plates template engine to Silex.
Installs: 6 360
Dependents: 0
Suggesters: 1
Security: 0
Stars: 3
Watchers: 0
Forks: 3
Open Issues: 1
Requires
- league/plates: >=1.0.8,<2.2-dev
Requires (Dev)
- phpunit/phpunit: ~4.1
- silex/silex: ~1.2
This package is auto-updated.
Last update: 2021-09-23 04:58:03 UTC
README
This project aims to provide integration of the Plates template engine into the Silex micro-framework. It's in the very early stages, so don't be surprised if the integration is less than optimal.
The project is based very heavily on the default TwigServiceProvider
and
some of the Symfony-Twig bridge extensions.
Usage
Add the provider to your composer.json
file:
{ "require": { "rych/silex-plates-provider": "1.0.*" } }
Enable it in your application:
<?php /* @var $app Silex\Application */ $app->register(new \Rych\Silex\Provider\PlatesServiceProvider(), array ( 'plates.path' => '/path/to/templates', // Required 'plates.folders' => array ( // Optional 'email' => '/path/to/email/templates'; ), )); $app->get('/', function () use ($app) { return $app['plates']->render('mytemplate'); });
Extensions
This provider also registers common extensions which work very similar to those found in the Symfony-Twig bridge. I hope to add more in the future, but right now I've only included the big ones I use regularly.
Routing Extension
Provides the url
and path
functions for generating URIs. This extension is
only available if UrlGeneratorServiceProvider
is registered.
Security Extension
Provides the is_granted
function. This extension is only available if
SecurityServiceProvider
is registered.
Custom Extensions
You may choose to register your own Plates extensions. This can be accomplished
easily by extending the plates.engine
service.
<?php /* @var $app Silex\Application */ $app['plates.engine'] = $app->share($app->extend('plates.engine', function($engine, $app) { $engine->addExtension(new \My_Plates_Extension()); return $engine; }));