Search code examples
grailsgsp

Grails.How to format Strings in bullet point


I want the div to be dynamic.The string that i get might contain bullet point like this a :"Uses •This is a test: •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test".

I have a div that shows the output:

                <div class="ds-results-detail-a">${a}</div>

How can i show that response in list like:

Uses 
•This is a test:
•This is a test 
•This is a test
•This is a test
•This is a test 
•This is a test
•This is a test 
•This is a test

The response might contain strings with those bullet point or may be simply String. The output simply shows like:

Uses •This is a test: •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test •This is a test

How to show in list?Thanks in advance :)


Solution

  • If I understood it right, you need to have smth like:

    <ul>
      <g:each in="${yourString.split( '•' )}" var="s">
        <li>${s}</li>
      </g:each>
    </ul>
    

    UPD:

    Another way:

    ${yourString.replaceAll( '•', '<br>•' )}