Skip to content


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:
grails create-tag-lib format
or with your favourite IDE or text editor.
import java.text.SimpleDateFormat
class FormatTagLib {
def dateFormat = { attrs, body ->
out << new SimpleDateFormat(attrs.format).format(attrs.value)
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.