我已经从Phptal切换到Twig:非常好的体验。然而,在phptal中,我使用了"tal: cache“来缓存一些代码块……使用Twig,我如何才能做到这一点呢?
发布于 2013-12-11 03:23:20
发布于 2012-10-03 22:16:49
在twig中,没有显式缓存某些块。
但twig会在不处于调试模式时缓存从模板创建的中间代码。
请看这里:
http://symfony.com/doc/current/book/templating.html#twig-template-caching
这是在symfony上下文中,但我猜这也可以独立工作。
然后,您可以在实例化Twig_Environment时使用以下内容指定它:
'cache' => 'cache/templates', // the place to cache to
'auto_reload' => true //reload template when changes are detected请看这里:
https://stackoverflow.com/questions/12656301
复制相似问题