Reputation: 797
Currently I have a sortCode 123456
and I would like this thing to be formatted into 12-34-56
in gsp file without using the controller.
Code, where the result is 12,34,56
<g:formatNumber number="${sortCode}" format="##,##" />
Any way to use replaceAll on the above code for example? Or the only way is to use the controller?
Upvotes: 0
Views: 181
Reputation: 3932
Try the following:
${g.formatNumber( [number: "${sortCode}", format: "##,##" ] ).replaceAll( ',', '-' )}
The above will fail if sortCode
is null/empty so best to protect with <g:if...
Upvotes: 1