zombor / kostache
Logic-less View/Mustache Module for the Kohana Framework
Installs: 2 097
Dependents: 2
Suggesters: 0
Security: 0
Stars: 138
Watchers: 11
Forks: 43
Open Issues: 8
Requires
- php: >=5.3.0
- mustache/mustache: ~2.6.0
This package is not auto-updated.
Last update: 2025-01-14 08:51:35 UTC
README
Kostache is a Kohana 3 module for using Mustache templates in your application.
Usage
To use, simply create a POPO (Plain Old PHP Object) like so:
<?php class View_Test { public $hello = 'world'; public function testing() { return 'foobar'; } }
And create a mustache renderer. The parameter to the engine method is the template name to use.
<?php $renderer = Kostache::factory();
And render it:
<?php $this->response->body($renderer->render(new View_Test));
Templates
Templates should go in the templates/
directory in your cascading file system. They should have a .mustache extension.
Partials
Partials are loaded automatically based on the name used in the template. So if you reference {{>foobar}}
in your template, it will look for that partial in templates/partials/foobar.mustache
.
Layouts
KOstache supports layouts. To use, just add a templates/layout.mustache
file (a simple one is already provided), and use Kostache_Layout
for your renderer instead of Kostache
. You'll probably want to put a $title
property in your view class. The layout should include a {{>content}}
partial to render the body of the page.
Additional Information
For specific usage and documentation, see: