public function testVoltCompilerImportRecursiveFile() { @unlink('unit-tests/views/partials/header3.volt.php'); @unlink('unit-tests/views/partials/header2.volt.php'); @unlink('unit-tests/views/test10/import2.volt.php'); $view = new Phalcon\Mvc\View(); $view->setViewsDir('unit-tests/views/'); $volt = new \Phalcon\Mvc\View\Engine\Volt\Compiler($view); //extends $volt->compileFile('unit-tests/views/test10/import2.volt', 'unit-tests/views/test10/import2.volt.php'); $compilation = file_get_contents('unit-tests/views/test10/import2.volt.php'); $this->assertEquals($compilation, '<div class="header"><h1>This is the title</h1></div>'); }
<?php //Create a compiler $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); //Optionally add some options $compiler->setOptions(array()); //Compile a template string returning PHP code echo $compiler->compileString('{{ "hello" }}'); //Compile a template in a file specifying the destination file $compiler->compileFile('layouts/main.volt', 'cache/layouts/main.volt.php'); //Compile a template in a file based on the options passed to the compiler $compiler->compile('layouts/main.volt'); //Require the compiled templated (optional) require $compiler->getCompiledPath();