Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Home

houbie edited this page · 3 revisions
Clone this wiki locally

Intro

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

Advantages:

  • 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.

Usage

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}"/>
    ${body()}
</label>

This tag can be used like any other tag:

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

TODO

  • 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.
Something went wrong with that request. Please try again.