Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

24 lines (16 sloc) 1.028 kb
h1. Tag Library Usage
A tag library fulfills role of "view helper" in the Model View Controller (MVC) pattern and helps with GSP rendering. In Grails a tag library is a class with a name that ends in the convention "TagLib" and lives in the @grails-app/taglib@ directory. Use the [create-tag-lib|commandLine] command create a tag library:
{code:java}
grails create-tag-lib format
{code}
or with your favourite IDE or text editor.
{code:java}
import java.text.SimpleDateFormat
class FormatTagLib {
def dateFormat = { attrs, body ->
out << new SimpleDateFormat(attrs.format).format(attrs.value)
}
}
{code}
Each Closure property in a tag library that takes one or two arguments is considered a tag. The first argument (typically named @attrs@) will contain the attributes of the tag whilst the optional second argument (typically named @body@) is Closure that represents the inner HTML of the tag declaration from the GSP.
Refer to the user guide topic on [Tag Libraries|guide:taglibs] for more information.
Jump to Line
Something went wrong with that request. Please try again.