Grails plugin that supports server-side compilation of .soy template files to .js files.
JavaScript Groovy
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Closure Templates Resources plug-in for Grails

This plug-in converts HTML templates into JavaScript functions using Google's Closure Templates.

Closure Templates Documentation:

Note: Google's Closure JavaScript library is not required to use Closure Templates.


Closure Templates allow you to compile HTML templates into JavaScript functions. The template file includes a namespace declaration followed by one or more templates.

Example file: webapp/soy/

{namespace grails.views.task}

 * @param name
 * @param dateDue
{template .show}
    <div>Name: {$name}</div>
    <div>Date Due: {$dateDue}</div>

 * @param taskInstanceList
{template .list}
        <th>Date Due</th>
      {foreach $taskInstance in $taskInstanceList}

You can invoke the template from JavaScript using the namespace and the template name like this:

var html ={name:'Pay bills', dateDue: '11/11/2011'});

The resulting html can then be inserted into the DOM:

document.getElementById('myContainer').innerHTML = html;

Full documentation can be found here.


modules = {

    task {
        dependsOn 'soyutils'

        resource url:'js/some-other-file.js'
        resource url: '/soy/', attrs:[type:'js']


  • The template file must have a .soy extension
  • attrs[type] must be set to 'js'
  • 'soyutils' must be in the dependsOn list. If you're using Google Closure JavaScript library, 'soyutils_usegoog' should be used instead.