转 Smaty是什么

 Smarty is a template engine for PHP.More specifically, it facilitates a manageable way to separate application logic and content from its presentation.

Smarty是一个php模板引擎。更准确的说,它分开了逻辑程序和外在的内容,提供了一种易于管理的方法。

This is best described in a situation where the application programmer and the template designer play different roles,or in most cases are not the same person.

可以描述为应用程序员和美工扮演了不同的角色,因为在大多数情况下,他们不可能是同一个人。

For example,let's say you are creating a web page that is displaying a newspaper article. The article headline,tagline,author and body are content elements, they contain no information about how they will be presented

例如,你正在创建一个用于浏览新闻的网页,新闻标题,标签栏,作者和内容等都是内容要素,他们并不包含应该怎样去呈现。

They are passed into Smarty by the application,then the template designer edits the templates and uses a combination of Html tags and template tags to format the presentation of these elements(HTML tables,background colors,font sizes,style sheets,etc.)One day the programmer needs to change the way the article content is retrieved(a change in application logic.)This change does not affect the template designer,the content will still arrive in the template exactly the same.Likewise,if the template designer wants to completely redesign the templates,this requires no changes to the application logic.

在smarty的程序里,这些被忽略了。模板设计者们编辑模板,组合使用HTML标签和模板标签去格式化这些要素的输出(HTML表格,背景色,字体大小,样式表,等等)。有一天程序员想要改变文章检索的方式(也就是程序逻辑的改变)。这个改变不影响模板设计者,内容仍将准确的输出到模板。同样的,那天美工吃多了想要完全重做界面,也不会影响到程序逻辑。

Therefore,the programmer can make changes to the application logic without the need to restructure templates,and the template designer can make changes to templetes without breaking application logic.

因此,程序员可以改变逻辑而不需要重新构建模板,模板设计者可以改变模板而不影响到逻辑。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值