Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Mustache templates in Grails
JavaScript Groovy
Latest commit 4e93b5b Edvinas Bartkus committed with Edvinas Test for Mustache Module declared with id next to file


Mustache Plugin

Integrate Mustache into your Grails project.

Mustache provides Logic-less templates that are a great tool for HTML layout, especially in the context of building javascript powered pages within a web browser. Now, thanks to, you can interpret Mustache templates from the server as well.

This plugin serves to enable both server-side and client-side use of Mustache while maintaining a DRY methodology (i.e. you can use the same Mustache templates on the client and server).


Two tags are provided in the “mustache” namespace; render and layoutTemplates


Renders inline Mustache template code or Mustache template files server-side. Inline Mustache templates can also be written as script elements within the page for use by javascript.


  • model: (required) The object instance to use as the data model for the template.
  • tid : The Document id to use for a script element for use by javascript
  • href : The path, relative to server root, of a Mustache template file.


Renders script elements for each of the inline templates that were given a tid attribute. In practice, this is placed near the closing tag for the body div element.


Example: Inline mustache with script generation

<mustache:render model="${user}" tid="user-greeting">
  Hello {{fullname}}. 
    We're glad you logged in.
<mustache:layoutResources />

Example: Using href

In web-app/tmplates/wax.mustache

Hello {{fullname}}. 
  We're glad you logged in.

In the GSP

<mustache:render model="${user}" href="/templates/wax.mustache"
Something went wrong with that request. Please try again.