Download the PHP package clippings/mustache-provider without Composer
On this page you can find all versions of the php package clippings/mustache-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download clippings/mustache-provider
More information about clippings/mustache-provider
Files in clippings/mustache-provider
Package mustache-provider
Short Description A Mustache service provider for Pimple and Silex.
License MIT
Homepage https://github.com/clippings/mustache-provider
Informations about the package mustache-provider
MustacheServiceProvider
Provides Mustache integration for the Pimple dependency-injection container or the Silex application micro-framework.
Installation
Add clippings/mustache-provider
to your project's Composer dependencies:
Configuration
-
mustache.path
(optional): Path to the directory containing Mustache template files. -
mustache.partials_path
(optional): Path to the directory containing Mustache partial template files. If none is specified, this will default tomustache.path
. -
mustache.partials
(optional): An associative array of template names to template contents. Use this if you want to define partials inline. -
mustache.helpers
(optional): An associative array of Mustache helpers. See the Mustache.php helpers documentation for more information. mustache.options
(optional): An associative array of Mustache options. See the Mustache.php documentation for more information.
Services
-
mustache.loader
(optional): A Mustache template loader instance. This loader will use themustache.path
option you provided. You can also replace the loader with something awesome of your own. mustache.partials_loader
(optional): The Mustache template loader used to load partials. By default, this will load templates from either your themustache.partials_path
ormustache.partials
configuration options. You can also replace the partials loader with another loader of your choice.
Registering
Usage
The Mustache provider provides a mustache
service:
This will render the hello.mustache
file from your application's views
directory.
Template Loading
The Mustache service provider ships with a Filesystem template loader enabled by
default. All you have to do to get things off the ground is set a
mustache.path
option to tell it where your templates live. But you can swap
that loader out for any other Mustache Loader.
For +10 Awesome, you should check out the Inline template loader:
The Trait
Mustache\MustacheApplicationTrait
adds a render
helper to your app:
Now you can just call render:
Or BYO Response:
It also provides a renderTemplate
helper which returns a rendered string
instead of a Response
object.
Customization
You can mess with Mustache before using it by extending the mustache
service: