We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt template - how escape parsing?

I need something like this:

https://www.smarty.net/docs/en/language.escaping.tpl

how to do it in phalcon?

As a workaround: Embed it in <?php blocks (echo or something), as Volt does not touch already existing PHP code in the templates.



2.2k

Thank for your help. I found other solution. In view my code is:

{{ include_raw('path_to_my_view') }}

include_raw code is:

$view->registerEngines(array(
    '.volt' => function($view, $di) {
        $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(array(
            'compiledPath' => '../app/compiled/',
            'compileAlways' => true 
        ));
        $compiler->addFunction('include_raw', function($resolvedArgs, $exprArgs) use ($view) {
            return sprintf('file_get_contents("%s" . %s)', $view->getViewsDir(), $resolvedArgs);
        });
        return $volt;
    }
));