什么是模板语言? [英] What is a templating language?

查看:1219
本文介绍了什么是模板语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处读到PHP是一种模板语言.什么是模板语言?是什么使PHP成为一体?其他模板语言是什么?

I was reading somewhere that PHP is a templating language. What is exactly a templating language? What makes PHP one? What are the other templating languages?

推荐答案

模板语言的前提是该语言嵌入"在其他一些主文档中.具体来说,在您的普通文档中,文档的总大小主要是文档来源,而不是模板语言.

The premise behind a template language is that the language is "embedded" within some other master document. Specifically, on your average document, the total size of the document is mostly document source than template language.

考虑两个人为的例子:

print "This is a simple document. It has three lines."
print "On the second line is my name: " + firstName
print "This is the third line."

vs

This is a simple document. It has three lines.
On the second line is my name: $firstName
This is the third line.

您可以在第一个示例中看到,该语言包装了文档文本.在第二个示例中,文档文本是最普遍的,只有一点点代码.

You can see in the first example, the language wraps the document text. In the second example, the document text is the most prevalent, with just a little bit of code.

某些模板语言是完整的通用语言,例如PHP,ASP.NET和Java的JSP.其他的则更受限制,专门为模板而设计,例如Velocity和FreeMarker(这两个都是Java实用程序).

Some template languages are full blown general purpose languages, such as PHP, ASP.NET, and Java's JSP. Others are more limited designed specifically for templating, such as Velocity and FreeMarker (both utilities for Java).

许多文字处理器(例如Microsoft Word)具有自己的模板功能,通常称为邮件合并".

Many word processors, such as Microsoft Word, have their own templating capabilities, commonly referred to as "Mail Merge".

这篇关于什么是模板语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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