laasti / views
A HTTP Message compatible template engine abstraction.
v0.2.3
2017-05-03 20:44 UTC
Requires
- psr/http-message: ~1.0
Requires (Dev)
- mustache/mustache: ~2.9.0
- zendframework/zend-diactoros: 1.3.3
README
A HTTP Message compatible template engine abstraction. Provides a TemplateStream that can be attached to HTTP Message's Response.
Only support PHP and Mustache (bobthecow/mustache.php) templates for the moment, PRs are welcome to add more engines.
Installation
composer require laasti/views
Usage
$renderer = new \Laasti\Views\TemplateRenderer; //You can add many engines to support multiple template types $renderer->addEngine(new \Laasti\Views\Engines\PlainPhp([/*View directory*/])); //You can set global data to pass on to all template $renderer->setData('sitename', 'Hello world!'); //Or you can pass data only to one template $template = new \Laasti\Views\Template("template-name.php", new \Laasti\Views\Data\ArrayData(['title' => 'Hello world!'])); //attackStream will create a TemplateStream and attach it to the response's body $response = $renderer->attachStream($response, $template); //The title and sitename will be available as $title and $sitename in the template
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
See Github's releases or tags
Credits
Author: Sonia Marquette (@nebulousGirl)
License
Released under the MIT License. See LICENSE.txt file.