6.3.2 Simple Tags - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: null
6.3.2 Simple Tags
As demonstrated it the previous example it is easy to write simple tags that have no body and just output content. Another example is adateFormat style tag:def dateFormat = { attrs, body ->
out << new java.text.SimpleDateFormat(attrs.format).format(attrs.date)
}SimpleDateFormat class to format a date and then write it to the response. The tag can then be used within a GSP as follows:<g:dateFormat format="dd-MM-yyyy" date="${new Date()}" />def formatBook = { attrs, body ->
out << "<div id="${attrs.book.id}">"
out << "Title : ${attrs.book.title}"
out << "</div>"
}def formatBook = { attrs, body ->
out << render(template: "bookTemplate", model: [book: attrs.book])
}
