FreeMarker
Purpose¶
Apache FreeMarker is a template engine: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language.
Note
The version of FreeMarker embedded in Platform 6 is configuration compatible with FreeMarker version 2.3.21.
Methods¶
Binding name: fm
Method: String process(String templateText, Map model)
Process a FreeMarker template and data model, returning the result as a String.
Examples¶
def model = [ user: "Jon Doe", latestProduct: [ name: "platform6", url: "www.amalto.com" ] ] def html = fm.process(resource.get("FMTEMPLATE"), model) println html
FMTEMPLATE
<html> <head><title>Welcome!</title></head> <body> <h1>Welcome ${user}!</h1> <p>Our latest product: <a href="${latestProduct.url}">${latestProduct.name}</a></p> </body> </html>