Reputation: 1901
I want to render a simple page so I can benchmark the performance. I use phalcon's volt engine
use Phalcon\Mvc\View\Engine\Volt\Compiler;
$c = new Compiler();
$c->setOptions(['compiledPath' => '/tmp/']);
$c->compile('hello.volt');
require $c->getCompiledTemplatePath();
is all my code how do I now give over a variable that can be rendered in hello.volt
Doing simple math like {{ 7 + 12 }} is all I could achieve so far :/
Upvotes: 2
Views: 765
Reputation: 4960
Have you tried this:
use Phalcon\Mvc\View\Engine\Volt\Compiler;
$c = new Compiler();
$c->setOptions(['compiledPath' => '/tmp/']);
$c->compile('hello.volt');
$variables = array(
'message' => 'world'
);
require $c->getCompiledTemplatePath();
Template:
{{ 'hello ' ~ variables['message'] }}
Compiled template is for real just a mixed PHP and HTML code. So once you are including it, you should be able to use there all variables that have been declared before including compiled template. In your case, $c
variable:
{{ dump(c) }}
Share us you benchmarks! Especially if you are comparing Phalcon 1.3.4 with Phalcon 2+. Difference should be visible.
Upvotes: 2