为什么要在模板框架中使用模板引擎? [英] Why use a templating engine with a framework?

查看:240
本文介绍了为什么要在模板框架中使用模板引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现了PHP框架 Kohana (很棒),并且正在阅读有关在其中使用它的线程.与诸如 Smarty

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 question is why bother? Surely an MVC framework, by definition, is a templating engine. Even "raw" PHP is, arguably, a templating engine. What possible benefits are there of adding another level of abstraction on top of what's already present in a framework such as Kohana?

编辑- 我意识到MVC框架与模板引擎不是同一回事,但可以肯定的是,V部分会完成相同的工作吗?也许用一种更好的措辞方式是;为什么在MVC框架的V部分顶部添加模板引擎?

EDIT - I realise that an MVC framework isn't the same thing as a templating engine, but surely the V part does the same job? Perhaps a better way of phrasing things would be; why add an templating engine on top of the V part of an MVC framework?

推荐答案

我有两个非常好的理由可以考虑...

I have two really good reasons I can think of for doing this...

  1. 创建以一致的格式在整个网站中重复的标记更加容易,而且您以后可以进行更新而无需花费很多精力.
  2. 如果这是一家真正的公司,那么确定内容的人不太可能真正熟悉HTML,更不用说PHP.拥有一种简单的模板语言,可以使样式保持正确的方式,并在无需太多代码知识的情况下即可生成有效的标记.

这篇关于为什么要在模板框架中使用模板引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆