Download the PHP package phly/phly-mustache without Composer
On this page you can find all versions of the php package phly/phly-mustache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phly/phly-mustache
More information about phly/phly-mustache
Files in phly/phly-mustache
Package phly-mustache
Short Description PHP Mustache implementation supporting inheritance
License BSD-2-Clause
Homepage http://phly-mustache.readthedocs.org
Informations about the package phly-mustache
phly-mustache
phly-mustache is a Mustache implementation written for PHP. It conforms to the principles of mustache, and allows for extension of the format via pragmas.
In particular, it offers support for template
inheritance ala
hogan.js, using the {{<parent}}
syntax.
For full documentation, please visit ReadTheDocs.
The mailing list is at https://groups.google.com/d/forum/phly_mustache
Installation
Install via composer:
Documentation
Documentation builds are available at:
You can also build documentation in one of two ways:
- MkDocs: Execute
mkdocs build
from the repository root. - Bookdown: Execute
bookdown doc/bookdown.json
from the repository root.
In each case, you can use PHP's built-in web server to serve the documentation:
and then browse to http://localhost:8080/.
Usage
Basic usage is:
By default, phly-mustache will look under the current directory for templates ending with '.mustache'; you can create a stack of directories using the default resolver:
In the above, it will search first $path2
, then $path1
to resolve the
template.
The default resolver is composed in an aggregate resolver by default; as such, you can also fetch it by type from the aggregate instead of adding it manually:
Template names may be namespaced, using the syntax namespace::template
:
Per the above configuratin, rendering the template contact::index
will resolve
to $path2
. If it cannot, it will drop back to the default namespace (any paths
registered without a namespace).
You may also change the suffix it will use to resolve templates:
If your templates use pragmas, you must first add pragma handlers to the
Mustache
pragma collection. This can be done as follows:
Views can be either associative arrays or objects. For objects, any public member, either a property or a method, may be referenced in your template. As an example:
Any property (or array key) may also refer to a valid callback; in such cases, the return value of the callback will be used.
Refer to the documentation (online / local) for full usage details.
Architecture
Phly\Mustache consists of five primary classes:
- Lexer: tokenizes mustache syntax.
- Renderer: renders a list of tokens, using substitions provided via a view.
- Pragma\PragmaInterface: interface for pragmas, which may modify how tokens are handled.
- Resolver\ResolverInterface: resolves a template name to mustache syntax or tokens.
- Mustache: facade/gateway class. Tokenizes and renders templates, caches tokens, provides partial aliasing, aggregates pragmas, and acts as primary interface for end-users.
All versions of phly-mustache with dependencies
zendframework/zend-stdlib Version ^2.6 || ^3.0
zendframework/zend-escaper Version ^2.5