[英]Phalcon Framework volt template engine
I want to render a simple page so I can benchmark the performance.我想呈现一个简单的页面,以便我可以对性能进行基准测试。 I use phalcon's volt engine
我使用 phalcon 的伏特引擎
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是我所有的代码,我现在如何提供可以在 hello.volt 中呈现的变量
Doing simple math like {{ 7 + 12 }} is all I could achieve so far :/像 {{ 7 + 12 }} 这样的简单数学是我目前所能做到的:/
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.编译后的模板实际上只是一个混合的 PHP 和 HTML 代码。 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:在您的情况下,
$c
变量:
{{ dump(c) }}
Share us you benchmarks!与我们分享您的基准! Especially if you are comparing Phalcon 1.3.4 with Phalcon 2+.
特别是当您将 Phalcon 1.3.4 与 Phalcon 2+ 进行比较时。 Difference should be visible.
差异应该是可见的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.