XpdWiki

FrontPage
RecentChanges
XtC
FindPage
PageIndex
XpApprentices

Set your name in
UserPreferences

Edit this page

Referenced by
JakartaVelocity
VPP




JSPWiki v2.0.52


FreeMarker


FreeMarker is a Java-based template engine. It was primary designed for generating dynamic HTML pages in Web applications that follow MVC (Model-View-Controller) design pattern. This means that the presentation and the Java code are separated. The Java program makes the dirty/complex work, and the page templates are kept stupid simple and concentrate on the presentation. An example FreeMarker template:

<html>
<body>
<h1>Hello ${name}!</h1>
<p>Our products:
<ul>
<#list products as product>
  <li>${product.name} for ${product.price}
</#list>
</ul>
</body>
</html>

Here, the Java program must put variables name and products into the, so-called, data model before invoking the template. It is up to the Java program how does it calculate the values of those variables. Maybe it queries them from a database. But, the template author, who is perhaps not a programmer, need not care. He just displays the already prepared data in the HTML page, using the embedded FreeMarker directives. (The FreeMarker directives are resolved on the server side by the FreeMarker engine.)

FreeMarker is used not only with Web applications and HTML. It is a general-purpose text preprocessor. For example, there is a FreeMarker based command-line tool and Ant task for preprocessing whatever text files, called FMPP:http://fmpp.sourceforge.net

FreeMarker homepage: http://freemarker.sourceforge.net/ (and mirror http://freemarker.org/)

Another, somewhat more light-weight template engine is Velocity.


Edit this page   More info...   Attach file...
This page last changed on 01-Oct-2003 23:37:23 BST by unknown.