koine / view
Simple View renderer
Installs: 943
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/koine/view
Requires
- php: >=5.4
- koine/core: 0.9.*
Requires (Dev)
- phpunit/phpunit: *
- satooshi/php-coveralls: dev-master
README
Simple view renderer for phtml files
Code information:
Package information:
Usage
$config = new \Koine\View\Config; $config->addPath('/path1') ->addPath('/path2') ->addPaths(array( 'path3', 'path4', )); $config->setHelper('escaper', new \MyEscaper()); $viewRenderer = new \Koine\View\Renderer($config); echo $viewRenderer->render('post_template.phtml', array( 'title' => 'Some Title', 'body' => 'Some content', 'relatedPosts' => $relatedPosts, ));
The templates:
<!-- post_template.phtml -->
<article>
<!-- either $this->escape() or $this->getHelper('escaper')->escape() will work -->
<h1><?= $this->escape($title) ?></h1>
<div class="body"><?= $this->getHelper('escaper')->escape($body) ?></div>
<?= $this->partial('related_posts.phtml', array(
'posts' => $relatedPosts
));
?>
</article>
<!-- _related_posts.phtml -->
<sidebar class="related">
<h2>Related Posts</h2>
<?php foreach ($posts as $post) : ?>
<?= $this->partial('related_post.phtml', array(
'title' => $post['title'],
'url' => $post['url'],
)) ?>
<?php endforeach ?>
</sidebar>
<!-- _related_post.phtml -->
<a href="<?= $this->getHelper('escaper')->escape($url) ?>"><?= $this->getHelper('escaper')->escape($title) ?></a>
Installing
Via Composer
Append the lib to your requirements key in your composer.json.
{ // composer.json // [..] require: { // append this line to your requirements "koine/view": "dev-master" } }
Alternative install
- Learn composer. You should not be looking for an alternative install. It is worth the time. Trust me ;-)
- Follow this set of instructions
Issues/Features proposals
Here is the issue tracker.
Contributing
Only TDD code will be accepted. Please follow the PSR-2 code standard.
- 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) - Create new Pull Request
How to run the tests:
phpunit --configuration tests/phpunit.xml
To check the code standard run:
phpcs --standard=PSR2 lib phpcs --standard=PSR2 tests