How to summarize a long text using Thymeleaf?

1

I have an object with two attributes, one is the id and the other is an attribute of the strring type called text of the type "TEXT" (postgres bank) that is used to store the text of a client post.

When the application loads these I would like to make a summary of this text.

I was able to do this using JSP, easily using forTokens .

How to do the same as the code below using the thymeleaf?

<p class="post-texto">
    <c:forTokens var="resumo" items="${p.texto}" delims=" " begin="0" end="60">
            ${resumo}
    </c:forTokens><a href="<c:url value="/${p.link}" />">[Continue lendo]</a>
</p>

I researched but found nothing similar to forTokens in thymeleaf.

    
asked by anonymous 28.03.2017 / 13:28

1 answer

0

You can use the abbreviate function of the #strings expression. For example:

<p th:text="${#strings.abbreviate(resumo,5)} "></p>

For more details on expressions follow the link

    
13.11.2018 / 22:15