Skip to content

Repository files navigation

Koine View

Simple view renderer for phtml files

Code information:

Build StatusCoverage StatusCode ClimateScrutinizer Code Quality

Package information:

Latest Stable VersionTotal DownloadsLatest Unstable VersionLicenseDependency Status

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>
<?phpforeach ($postsas$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

Issues/Features proposals

Here is the issue tracker.

Contributing

Only TDD code will be accepted. Please follow the PSR-2 code standard.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. 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

Lincense

MIT

Authors

About

Simple view renderer for phtml files

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages