Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Ceil, Floor, ROund + Volt

Is it possible to use this php function directly in volt engine ?



2.5k
Accepted
answer

$compiler = $volt->getCompiler(); $compiler->addFilter('round','round');



4.0k

Hi, you can write own custom view helper http://docs.phalconphp.com/en/latest/reference/tags.html#creating-your-own-helpers

example:

class Number extends \Phalcon\Tag 
{
    public function round($number, $precision = 0 $mode = PHP_ROUND_HALF_UP)
    {
        return round($number, $precision, $mode); 
    }

    another methods
}

and then in volt

{{ Number.round(100.256, 2) }}