Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

Latest commit

 

History

History
37 lines (24 loc) · 1.33 KB

README.md

File metadata and controls

37 lines (24 loc) · 1.33 KB

MustacheServiceProvider

Provides integration with Mustache.php for the Silex microframework.

Parameters

  • mustache.extension: Extension for template and partials files. Defaults to mustache.
  • mustache.options: An array of options to be passed to the Mustache_Engine constructor.
  • mustache.templates_path (optional): Path to directory containing the templates.
  • mustache.partials_path (optional): Path to the directory containing partials.

If mustache.templates_path or mustache.partials_path are set and no corresponding loader is defined in mustache.options, filesystem loaders will be created automatically.

Services

  • mustache: The Mustache instance.

Usage Example

Registering with the application

$app->register(new \Concedra\Silex\MustacheServiceProvider(), array(
    'mustache.templates_path' => '/path/to/template_directory',
    'mustache.partials_path' => '/path/to/partials_directory',
));

Rendering content

// inside controller, will look for `template.mustache` in `mustache.templates_path`
$app['mustache']->render('template', array('variable' => 'value'));

See also