Created
December 22, 2011 17:20
-
-
Save RGBz/1511069 to your computer and use it in GitHub Desktop.
Grails truncate tag with abbr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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