FreeMarker, a template engine for the Java platform, the placeholder is replaced in text files with dynamic content. The most common application is to generate HTML in web applications, but it is inter alia also used to generate emails, source code and SQL queries. FreeMarker is free software.

FTL FreeMarker Template Language

FreeMarker uses its own simple programming language ( DSL) that is optimized for use in HTML templates.

The content of the variable is in the form of $ { variable} issued instructions listed as <# statement ... / >. Frequently used instruction blocks can be defined as a macro, and then in the form < @ macro ... / > call (commands and macros can have parameters so that should indicate "...").

FTL provides a comparatively wide range of functions, it can be such as numbers and date values ​​spend internationalized, perform character substitutions with regular expressions, provided texts for use in JavaScript using wildcard characters (also) Sorting lists by Subvariablen of the elements or DOM nodes in XML documents address.


Suppose there are the variables name (a string ) and items ( quantity a list of objects with the fields and description ) are available.

The template

Then produces the following output:

Basket for John Doe:

  • 1 pcs pencil   
  • 2 pcs eraser applications

    FreeMarker is used in various areas of software engineering and is used by many programs and frameworks used respectively. supported.

    • In Web applications is FreeMarker as an alternative to JSP for use. The widespread frameworks Struts and Spring offer this FreeMarker to ( as another alternative is Apache Velocity available ). As in FreeMarker using JSP taglibs to be possible, when moving from JSP to FreeMarker not on the required taglibs (such as the Struts taglib ) can be omitted.
    • Struts 2 uses FreeMarker internally for rendering JSP, Velocity and FreeMarker tags after the predecessor project WebWork had undergone a change from Velocity to FreeMarker.
    • Content management systems such as Magnolia use FreeMarker templating engine.
    • In code generators is dynamically generated with FreeMarker source code ( Java, SQL, RTF, PostScript).
    • The tools of the persistence framework Hibernate use FreeMarker when generating database schemas, SQL and Java code. 2006, a change from Velocity to FreeMarker place ( including improved error handling).
    • NetBeans IDE uses FreeMarker internally to fill in " New File ... " Wizard template documents with dynamic content.

    In IDEs such as Eclipse, NetBeans IDE IntelliJ IDEA or the processing of FreeMarker templates by syntax check, code completion, pop-up help is like supported.


    FreeMarker 1 was developed by Benjamin Geer and Mike Bayer and published in January 1999 under the LGPL license ( still called " FreeMarker classic" available ).

    2002, the core of Jonathan Revusky was E. A. rewritten and published as FreeMarker 2 under the (compared to the LGPL) liberal BSD license.