...
Version 2.2, June 15, 2006
Related material:
...
Contents
- #Introduction
- #Motivation And Philosophy
- #Defining Templates
- #StringTemplate Group Files
- #Functionality
- #Functionality Summary
- #Object Rendering
- #Template Inheritance
- #Template And Attribute Lookup Rules
- #Setting the Expression Delimiters
- #Caching
- #Output Filters
- #Examples
- #StringTemplate Grammar
- #A Common Syntax Question
- #Acknowledgements
Related material
Please see the changes and bugs page. That page generally discusses the Java version of StringTemplate but, some of the information it contains might apply to other implementations.
...
Java |
|
---|---|
C# |
|
Python |
|
Additionally, it It is highly recommended that you read the (academically-oriented) paper, Enforcing Model-View Separation in Template Engines. There are some more examples including nested menu generation that will be of interest. You may also find the following resources useful or interesting:
- DRAFT A Functional Language For Generating Structured Text
- Internationalization and Localization of Web Applications In Action
- Language Translation Using ANTLR and StringTemplate
- Intelligent Web Site Page Generation
- The Role of Template Engines in Code Generation
Introduction
Most programs that emit source code or other text output are unstructured blobs of generation logic interspersed with print statements. The primary reason is the lack of suitable tools and formalisms. The proper formalism is that of an output grammar because you are not generating random characters--you are generating sentences in an output language. This is analogous to using a grammar to describe the structure of input sentences. Rather than building a parser by hand, most programmers will use a parser generator. Similarly, we need some form of unparser generator to generate text. The most convenient manifestation of the output grammar is a template engine such as StringTemplate
.
...