Download the PHP package mustache/silex-provider without Composer
On this page you can find all versions of the php package mustache/silex-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mustache/silex-provider
More information about mustache/silex-provider
Files in mustache/silex-provider
Package silex-provider
Short Description A Mustache service provider for Silex.
License MIT
Homepage https://github.com/bobthecow/mustache-silex-provider
Informations about the package silex-provider
MustacheServiceProvider
MustacheServiceProvider
provides Mustache integration for the
Silex application micro-framework.
Installation
Add mustache/silex-provider
to your project's composer.json
:
And install:
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\Silex\Application\MustacheTrait
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: