词条 | Template processor |
释义 |
A template processor (also known as a template engine or template parser) is software designed to combine templates with a data model to produce result documents.[1][2][3] The language that the templates are written in is known as a template language or templating language. For purposes of this article, a result document is any kind of formatted output, including documents, web pages, or source code (in source code generation), either in whole or in fragments. A template engine is ordinarily included as a part of a web template system or application framework, and may be used also as a preprocessor or filter. Typical featuresTemplate engines typically include features common to most high-level programming languages, with an emphasis on features for processing plain text. Such features include:
Embedded template enginesWhile template processors are typically a separate piece of software, used as part of a system or framework, simple templating languages are commonly included in the string processing features of general-purpose programming languages, and in text processing programs, notably text editors or word processors. The templating languages are generally simple substitution-only languages, in contrast to the more sophisticated facilities in full-blown template processors, but may contain some logic. Simple examples include print format strings, found in many programming languages, and snippets, found in a number of text editors and source code editors. In word processors, templates are a common feature, while automatic filling in of the templates is often referred to as mail merge. An illustrative example of the complementary nature of parsing and templating is the System elementsAll template processing systems consist of at least these primary elements:
Data modelThis may be a relational database, a source file such as XML, an alternate format of flat file database, a spreadsheet or any of other various sources of preformatted data. Some template processing systems are limited in the types of data that can be used. Others are designed for maximum flexibility and allow many different types of data. Source templateSource templates are traditionally specified:
Template engineThe template engine is responsible for:
Additionally some template engines allow additional configuration options. Result documentsThese may consist of an entire document or a document fragment. UsesTemplate processing is used in various contexts for different purposes. The specific purpose is ordinarily contingent upon the software application or template engine in use. However, the flexibility of template processing systems often enables unconventional uses for purposes not originally intended by the original designers. Template engineA template engine is a specific kind of template processing module that exhibits all of the major features of a modern programming language. The term template engine evolved as a generalized description of programming languages whose primary or exclusive purpose was to process templates and data to output text. The use of this term is most notably applied to web development using a web template system, and it is also applied to other contexts as well.[4] Document generationDocument generation frameworks typically use template processing as the central model for generating documents. Source code generationSource code generation tools support generation of source code (as the result documents) from abstract data models (e.g., UML, relational data, domain-specific enterprise data stores) for particular application domains, particular organizations, or in simplifying the production process for computer programmers. Software functionalityA web template engine processes web templates and source data (typically from a relational database) to produce one or more output web pages or page fragments. It is ordinarily included as a part of a web template system or application framework. Currently, template processing software is most frequently used in the context of development for the web. Comparison{{further|Comparison of web template engines}}XSLT is a template processing model designed by W3C. It is designed primarily for transformations on XML data (into web documents or other output). Programming languages such as Perl, Python, PHP, Ruby, C#, and Java support template processing either natively, or through add-on libraries and modules. JavaServer Pages,[5] Active Server Pages,[6] Genshi (for Python), and eRuby are examples of template engines designed specifically for web application development. Moreover, template processing is sometimes included as a sub-feature of software packages like text editors, IDEs and relational database management systems. Benefits of using template engines
See also
References1. ^{{cite book | last = Niemeyer | first = Patrick | title = Learning Java | publisher = O'Reilly | location = Sebastopol | year = 2002 | isbn = 0-596-00285-8 }} 2. ^{{cite book | last = Manolescu | first = Dragos | title = Pattern Languages of Program Design 5 | publisher = Addison-Wesley Professional | location = Reading | year = 2006 | isbn = 0-321-32194-4 }} 3. ^{{cite book | last = Fowler | first = Martin | title = Patterns of Enterprise Application Architecture | publisher = Addison-Wesley | location = Boston | year = 2003 | isbn = 0-321-12742-0 }} 4. ^(see e.g., Velocity, TemplateToolkit, Freemarker ). 5. ^JavaServer Pages is a technology released by Sun for use with the Java programming language.{{cite web |url=http://java.sun.com/products/jsp/faq.html#1 |title=JavaServer Pages Technology |date=2006-10-10 |accessdate=2006-10-10}} 6. ^ASP 1.0 was originally released for use with Microsoft VBScript and JScript.It was an extension to Microsoft IIS. External links
2 : Scripting languages|Template engines |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。