Template Types

Templates are text files containing processing instructions in markup and template languages to form web pages. Templates are parsed by a template engine, and the resulting page returned as a response to an HTTP request. The template engines currently supported by Tammi are Velocity, FreeMarker and JSP. You can customize template processing by implementing additional template builders, but in most cases the default builders are sufficient.

When naming and organizing template files according to Tammi guidelines and configuring the framework to meet your expectations, you will get a flexible system, where Tammi dynamically resolves the appropriate template for a particular user agent.

Layouts

Layouts are shared templates applied to all pages during template processing. The use of layouts is optional, but they are convenient for specifying elements, like headers and footers, to appear on each page.

By changing the layout, you can provide different look-and-feels. For example, you can apply different cascading style sheets (CSS) in different layouts to define alternative settings for fonts, colors and other effects.

Another use of layouts is to apply different definitions, like <!DOCTYPE> and <head>, to alternative markup languages and user agents.

Note that you can freely mix, even in the same page, layouts and templates written in different template languages and parsed by different template engines.

Velocity Sample

Tammi manual has been written in the Velocity template language. The TemplateDemo.vm sample gives a brief introduction to VTL syntax.

FreeMarker Sample

FreeMarker is an alternative template engine supported by Tammi. The TemplateDemo.ftl sample gives a brief introduction to FTL syntax.

JavaServer Pages (JSP) Sample

When running Tammi in a J2EE servlet container, such as Tomcat or Jetty, you can also apply JSP to produce web pages. Tammi's template search mechanism supporting localization and terminal adaptation is available for JSP templates also. The TemplateDemo.jsp sample demonstrates JSP support.

In order to try the JSP sample above, you need to build Tammi war, deploy it to a servlet container, and run it as a servlet.