Skip to content

Instantly share code, notes, and snippets.

@acreeger
Forked from RGBz/truncate-abbr
Created January 6, 2012 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acreeger/1572246 to your computer and use it in GitHub Desktop.
Save acreeger/1572246 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