GFreeMarker Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Contribution Overview

GFreeMarker is an integration of the FreeMarker template engine for Groovy. It allows adding plugins written in Groovy for content rendering, making FreeMarker+Groovy just as easy as Smarty. This way of doing avoids security issues related to allowing direct Groovy scripting in templates. With GFreeMarker, you create plugins, and make it available to customers.

Team Members

Cedric Champeau <cedric dot champeau at lingway dot com>







How does it work ?

Imagine your customer requires an URL Encoding text transform, and that FreeMarker does not offer this transformation. Then, you would just need to :

  • Create a plugin named urlencoder that implements the IGroovyFreeMarkerPlugin interface
  • Copy this plugin into the Groovy FreeMarker template engine plugins directory

That's all ! Now your customer can access it quite directly in the template. For example :

Writing a plugin

Here's a sample plugin which converts a string through URL encoder :

Using the template engine

Here's a sample code which shows how easy it is to embed FreeMarker as a template engine for Groovy.

This code assumes a directory called plugins is in the working directory. The template engine will dynamically load the ''urlencoder'' class.



GFreeMarker uses Maven2 as its build tool. Follow the instructions at or install an IDE which has Maven 2 support (I personally use IntelliJ IDEA 7).


Feel free to contribute, as I don't have much time to spend on this project.


Issue tracker




Results of your search request can come from various sources: the Groovy website itself, the JIRA issues, the API documentation, as well as a few other interesting Groovy-related blogs.

  By  -  pages  -  views  - last modified