有什么好处以及何时在 Codeigniter 中使用模板库而不是视图


what are the benefits and when to use template library rather than views in codeigniter

例如:

$this->load->model('home_module'); //loading a model in controller
$this->data["links"]=$this->home_module->create_links();
$this->data["banner"]=$this->home_module->get_banner();          
$this->page_title='Title';
$this->template
    ->set_layout('general')
    ->enable_parser(FALSE)
    ->title($this->page_title)
    ->build('body', $this->data);

我的问题是如何使用视图完成同样的事情,哪个在性能方面更好!!

模板解析器是视图文件的额外开销 - 但它在性能方面的牺牲,您可能会获得可读性:

注意:CodeIgniter 不需要你使用这个类,因为在视图页面中使用纯 PHP 可以让它们运行得更快一些。但是,一些开发人员更喜欢使用模板引擎,如果他们与他们认为在使用PHP时会感到困惑的设计师一起工作。

http://ellislab.com/codeigniter/user-guide/libraries/parser.html