Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

php - What is a templating language?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Consider two contrived examples:

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.

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).

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...