venca-x/nette-stargazer

Nette addon. Convert round numer to stars

1.0.0 2018-01-09 20:54 UTC

README

Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

Nette plugin for showing score as stars. You define positive and negavide symbols for ratio visualisation.

Version PHP    Recommended Nette
dev-master >= 7.1 Nette 3.0
1.0.x >= 5.5 Nette 2.4, 2.3

Installation

Install plugin to your dependencies with composer:

composer require venca-x/nette-stargazer:^1.0

For dev version install:

composer require venca-x/nette-stargazer:dev-master

Usage Sample

BasePresenter.php

protected function beforeRender()
{
    parent::beforeRender();

    $this->template->addFilter('stargazer', function ($text) {
        //$stargazer = new VencaX\Stargazer('<i class="fa fa-star"></i>', '<i class="fa fa-star-o"></i>');
        //$stargazer = new VencaX\Stargazer();
        $stargazer = new VencaX\Stargazer($star = "1", $starEmpty = "0", $starCount = 10);
        return $stargazer->makeStargazer($text);
    });
}

MyPresenter.php

protected function renderDefault()
{
    $this->template->score = 5;
}

Usage

{$o->score|stargazer|noescape}
{$o->score|stargazer}

Output

*****00000