将 PHPTAL 模板引擎集成到 yii 框架中 [英] Integrate PHPTAL template engine into yii framework
问题描述
我想知道如何将 PHPTAL 集成到 yii 框架中?我使用 PHPTAL 已经很长时间了,它是一个不错的模板引擎.虽然 Yii 允许将另一个模板引擎集成到框架中,但它仍然不支持 PHPTAL.
I'm wondering that how to integrate PHPTAL into yii framework? I'm using PHPTAL for a long time and it's nice template engine. Although Yii allows integrate another template engine into framework but it still does not support PHPTAL.
感谢您的帮助.
推荐答案
看看这个 Smarty 模板引擎的扩展:智能视图渲染器
Have a look at this extension for Smarty template engine: smarty-view-renderer
基本上,您为 Yii 编写一个实现 IViewRenderer
的组件.然后覆盖 init()
并实现 renderFile()
,然后在你的 main.php
配置文件中,你设置 viewRenderer
到您的 Component 类.像这样:
Basically, you write a Component for Yii that implements IViewRenderer
. Then override init()
and implement renderFile()
, and then in your main.php
config file, you set viewRenderer
to your Component class. Something like this:
'components' => array(
...
'viewRenderer'=>array(
'class'=>'application.extensions.path.to.your.class',
'fileExtension' => '.ext', // file extension to be handled by PHPTAL
//other configurations for your component
),
它会像魅力一样发挥作用.
and it will work like a charm.
但如果您不坚持使用 PHPTAL,Smarty 已经为您准备好了.
But if you don't insist on PHPTAL, Smarty is there ready for you.
这篇关于将 PHPTAL 模板引擎集成到 yii 框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!