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

how to render a compiled volt.php file

I am trying to excute the compiled volt files (The one converted to php).

Is there is a way to excute it and get the final html content

$eventsManager->attach('view:beforeRenderView', function($event, $view) use ($di, $cache) {

    $voltDir = $view->getActiveRenderPath();            
    $cachedVolt = $cache->get($voltDir);
                if(empty($cachedVolt)){

                    $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler();

                    $name = md5($voltDir);

                    $compiledVolt = $compiler->compileFile($voltDir, '/path/to/compiled-volt/'.$name.'.php');

                    //What I should do to convert it from php to final html.

                    $view->setContent(/* Final HTML */);

    }              
});

Probably you need to require the resulting PHP, however there could be resources that aren't available:

require '/path/to/compiled-volt/'.$name.'.php';

I tried this but I faced a problem that all methods used by volt like partial(), image() , linkTo(), ... etc are alll not defined :(