模板语言背后的前提是语言在其他主文档中“嵌入”。具体来说,在平均文档中,文档的总大小主要是文档来源而不是模板语言。
考虑两个例子:
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.
您可以在第一个示例中看到,该语言包装文档文本。在第二个例子中,文档文本是最流行的,只需一点点代码。
一些模板语言是完整的通用语言,如PHP,ASP.NET和Java的JSP。其他的更专门用于模板化,例如Velocity和FreeMarker(Java的两个实用程序)。
许多文字处理器(如Microsoft Word)都有自己的模板功能,通常被称为“邮件合并”。