Skip to content

Instantly share code, notes, and snippets.

@RGBz
Created December 22, 2011 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save RGBz/1511069 to your computer and use it in GitHub Desktop.
Save RGBz/1511069 to your computer and use it in GitHub Desktop.
Grails truncate tag with abbr
def truncate = { attrs, body ->
if (body().length() > attrs.maxlength.toInteger()) {
out << """<abbr title="${body()}">${body()[0..attrs.maxlength.toInteger() - 1]}...</abbr>"""
} else {
out << body()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment