houbie edited this page May 26, 2011 · 3 revisions
Clone this wiki locally


The gsp-taglib grails plugin makes it possible to declare tags in a gsp in grails-app/taglib.


  • Tags that contain mostly markup, read much better in a gsp. Also, IDE's provide good code completion for markup in gsp's.
  • Compared to using templates with the tmpl: tag, tags have a far better performance and better support for code completion.


Example grails-app/taglib/com/acme/label.gsp:

<%@ page import="com.acme.foo.*" %>
<%@ page namespace="my" %>

     * @attr code REQUIRED i18n message code
     * @attr bind REQUIRED
     * @attr styleClass OPTIONAL
<label for="${attrs.bind}" class="label ${attrs.styleClass}">
    <g:message code="${attrs.code}"/>

This tag can be used like any other tag:

<my:label code="person.name" bind="person">
    <span class="required">*</span>


  • Currently the generated groovy code is written in grails-app/taglib and will end up in your VCS. The goal is to load gsp tags dynamic with pre-compilation in war-mode (like gsp's).
  • The code is generated by a hacked copy of GroovyPageParser.groovy. GroovyPageParser should be refactored to have more protected members that can be accessed and/or overridden.
  • The ultimate goal is to get gsp tags into grails core as first class citizens.