Plugins You can find out about all the publicly available Grails plugins.

FreeMarker Grails Plugin

  • Authors: Jeff Brown
1 vote
compile "org.grails.plugins:freemarker:0.4"



SEE github README for the latest 2.0 version and GRAILS 3 updates



The Grails FreeMarker plugin provides support for rendering FreeMarker templates as views.

Getting Started

Installing The FreeMarker Plugin

Install the FreeMarker plugin with the install-plugin command:

grails install-plugin freemarker

Rendering FreeMarker Templates

The FreeMarker plugin supports rendering FreeMarker templates as views. FreeMarker templates should be defined below the views/ directory in the same places where you might define GSP views. For example, if you have a controller named DemoController that looks like this:

class DemoController {

def index = { [name: 'Jeff Beck', instrument: 'Guitar'] }


Then you could define a FreeMarker template in grails-app/views/demo/index.ftl that looks like this:

  Name: ${name} <br/>
  Instrument: ${instrument}<br/>

FreeMarker Tag Library

The FreeMarker plugin contributes a tag called render which is defined in the fm namespace. The tag works much like the render tag that is bundled with grails except that it renders FreeMarker templates instead of GSPs. The template supports the template and model attributes and may be used from any GSP. The following example shows the tag being used from a GSP.

  <fm:render template="myFreeMarkerTemplate" model="[name: 'Jake']"/>


Per, in applications with more than one view resolver, UrlMappings.groovy may need to be updated. . When adding this plugin to an existing grails project that also uses .gsp by default the "/" mapping will be indeterminate. Fix by setting "/"(view:"/index.gsp") or "/"(view:"/index.ftl") if that is what you want to use.

More Information

For more information on FreeMarker see the FreeMarker site.

Release Notes

Version 0.3

  • Upgrade to FreeMarker 2.3.16
  • Improve access to flash scope in a FreeMarker template

Version 0.4

  • Adding FreemarkerViewService and FreemarkerTemplateService
  • Packages renamed