コード例 #1
0
 public function testVoltCompileFileExtendsMultiple()
 {
     @unlink('unit-tests/views/templates/a.volt%%e%%.php');
     @unlink('unit-tests/views/templates/b.volt%%e%%.php');
     @unlink('unit-tests/views/templates/c.volt.php');
     $volt = new \Phalcon\Mvc\View\Engine\Volt\Compiler();
     //With blocks and extending
     $volt->compile('unit-tests/views/templates/c.volt');
     $compilation = trim(file_get_contents('unit-tests/views/templates/c.volt.php'));
     $this->assertEquals($compilation, "[A[###[B]###]]");
 }
<?php

$compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler();
$compiler->compile('views/partials/header.volt');
require $compiler->getCompiledTemplatePath();
コード例 #3
0
ファイル: volt-1231.php プロジェクト: aodkrisda/phalcon-code
<?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();