2017 © Pedro Peláez
 

library silex-plates

A Plates template engine service provider for the Silex micro-framework

image

liquidbox/silex-plates

A Plates template engine service provider for the Silex micro-framework

  • Saturday, December 2, 2017
  • by liquidbox
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,425 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 25 % Grown

The README.md

GitHub release license Build Status Code Coverage Scrutinizer Code Quality Packagist, (*1)

You are reading the documentation for Silex 2.x. Switch to the documentation for Silex 1.x., (*2)

Plates

The PlatesServiceProvider provides integration with the Plates template engine., (*3)

Parameters

  • plates.directory (optional): The default template directory.
  • plates.file_extension (optional): The template file extension.
  • plates.folders (optional): A collection of template folders to add for grouping templates under different namespaces.
  • plates.data (optional): A collection of data shared with all templates to add.
  • plates.functions (optional): A collection of template functions to register.
  • plates.extension.asset (optional): The asset extension directory to load that adds the ability to create "cache busted" asset URLs.

Services

  • plates: The Engine instance. The main way of interacting with Plates.
  • plates.engine_factory: Factory for Engine instances.
  • plates.loader: The loader for Plates templates which uses the plates.folders, plates.data, and plates.functions options.
  • plates.extension_loader.asset: Create new Asset extension instance that adds the ability to create "cache busted" asset URLs.

Registering

$app->register(new \LiquidBox\Silex\Provider\PlatesServiceProvider(), array(
    'plates.directory' => '/path/to/templates',
    'plates.folders' => array(
        'email' => '/path/to/email/templates',
    ),
));

Add Plates as a dependency:, (*4)

composer require liquidbox/silex-plates:^2.0

Usage

// Add any additional folders
$app['plates']->addFolder('emails', '/path/to/emails');

// Load asset extension
$app['plates.extension_loader.asset']('/path/to/public');

// Create a new template
$template = $app['plates']->make('emails::welcome');

Symfony Components Integration

The PlatesServiceProvider provides additional integration between some Symfony components and Plates. This will provide you with the following additional capabilities., (*5)

Routing Support

If you are using the UrlGeneratorServiceProvider, you will have access to the path() and url() functions. You can find more information in the Symfony Routing documentation., (*6)

Security Support

If you are using the SecurityServiceProvider, you will have access to the is_granted() function in templates. You can find more information in the Symfony Security documentation., (*7)

Customization

You can configure the Plates environment before using it when registering the plates service:, (*8)

$app->register(new \LiquidBox\Silex\Provider\PlatesServiceProvider(), array(
    'plates.data' => array(
        'title' => 'Plates - Native PHP Templates',
    ),
    'plates.functions' => array(
        'uppercase' => function ($string) {
            return strtoupper($string);
        },
    ),
));

For more information, check out the official Plates documentation., (*9)

The Versions

02/12 2017

dev-master

9999999-dev

A Plates template engine service provider for the Silex micro-framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan-Paul Marois

service template php silex html league engine provider plates thephpleague

02/12 2017

v2.0.0

2.0.0.0

A Plates template engine service provider for the Silex micro-framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan-Paul Marois

service template php silex html league engine provider plates thephpleague

02/12 2017

v1.0.0

1.0.0.0

A Plates template engine service provider for the Silex micro-framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan-Paul Marois

service template php silex html league engine provider plates thephpleague