XpdWiki
Set your name in
UserPreferences Edit this page Referenced by
JSPWiki v2.0.52
![]() ![]() |
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/ Another, somewhat more light-weight template engine is Velocity.
|