Phalcon\Test\Unit\Mvc\View\Engine\Volt\CompilerTest::testVoltUsersFilters PHP Method

testVoltUsersFilters() public method

    public function testVoltUsersFilters()
    {
        $this->specify("Custom filters should work", function () {
            $volt = new Compiler();
            //Single string filter
            $volt->addFilter('reverse', 'strrev');
            //Filter with closure
            $volt->addFilter('separate', function ($arguments, $exprArguments) {
                return 'explode(",", ' . $arguments . ')';
            });
            $compilation = $volt->compileString('{{ "hello"|reverse }}');
            expect($compilation)->equals('<?= strrev(\'hello\') ?>');
            $compilation = $volt->compileString('{{ "1,2,3,4"|separate }}');
            expect($compilation)->equals('<?= explode(",", \'1,2,3,4\') ?>');
        });
    }