Grails
  1. Grails
  2. GRAILS-7171

Provide a standard tag to trim/abbreviate text in GSPs

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.3.6
    • Fix Version/s: None
    • Component/s: TagLib
    • Labels:
      None

      Description

      A common need in GSPs is to shorten long text with elipsis ...
      I know it's not that difficult for app developers to add a method to String metaclass or mixin StringUtils from Commons Lang in BootStrap. But I think this is so common that a standard grails tag must support it.

      I can see two alternatives:

      1. add optional int parameter "abbreviate" to the existing fieldValue tag.
      2. add a new "abbreviate" tag with "bean" and "field" parameters like fieldValue and a "maxlength" parameter to set max text length.

      See abbreviate method in http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html

        Activity

        Hide
        Alexander Zeillinger added a comment -

        This should be useful, it got my vote.
        I'm in favour of adding a parameter to the fieldValue tag.

        Show
        Alexander Zeillinger added a comment - This should be useful, it got my vote. I'm in favour of adding a parameter to the fieldValue tag.
        Hide
        Marc Palmer added a comment - - edited

        Luke Daley I think has a high quality implementation of this. I think there are issues with the commons stuff.
        I think it was his implementation that allows the ellipsis at start, middle or end - which is very handy.

        A tied-in issue is cleaning up HTML to plain text before you summarize. Summarizing HTML gives bad markup

        Show
        Marc Palmer added a comment - - edited Luke Daley I think has a high quality implementation of this. I think there are issues with the commons stuff. I think it was his implementation that allows the ellipsis at start, middle or end - which is very handy. A tied-in issue is cleaning up HTML to plain text before you summarize. Summarizing HTML gives bad markup

          People

          • Assignee:
            Unassigned
            Reporter:
            Goran Ehrsson
          • Votes:
            4 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development