Why use a templating engine with a framework?

后端 未结 6 1269
迷失自我
迷失自我 2021-02-05 02:56

I recently discovered the PHP framework Kohana (which is awesome) and was reading a thread about using it in conjunction with a templating engine such as Smarty or Twig. My ques

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 03:20

    Firstly, raw PHP is NOT a templating engine.

    Next, MVC framework defines that the framework is split into Model, View and Control. It does not mean that the framework has a template engine, though the View may be integrated with a native or external template engine. Thus the framework may or may not have a templating engine.

    Thirdly, View != template. View is only referring to how data is displayed - there is no template involved usually, whereas template engine refers to a piece of code able to put data nicely into templates - which you can greatly reduce the need to modify all files when you can modify them in the templates

    Lastly, framework users may prefer to use a more common templating engine such as Smarty over the native template engine in the framework. You do not need to learn the new tags in the native template engine.

提交回复
热议问题