我想呈现一个简单的页面,这样我就可以对性能进行基准测试。我用的是phalcon的volt引擎
use Phalcon\Mvc\View\Engine\Volt\Compiler;
$c = new Compiler();
$c->setOptions(['compiledPath' => '/tmp/']);
$c->compile('hello.volt');
require $c->getCompiledTemplatePath();是我的全部代码,现在如何传递可以在hello.volt中呈现的变量
到目前为止,我只能做到像{{ 7+ 12 }}这样的简单数学运算:/
发布于 2015-10-29 23:10:32
你有没有试过这个:
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();模板:
{{ 'hello ' ~ variables['message'] }}编译好的模板是真正的PHP和HTML混合的代码。所以一旦你包含了它,你就应该能够使用在包含编译后的模板之前已经声明的所有变量。在您的示例中,使用$c变量:
{{ dump(c) }}与我们分享你的基准!尤其是在比较Phalcon1.3.4和Phalcon 2+的时候。差异应该是可见的。
https://stackoverflow.com/questions/33416900
复制相似问题