Groovy - list to String with message.properties

Is there any Groovy method which converts List to String with values substituted from message properties?

<g:message code="label.promotion.create.short.${command.daysList.join(",")}"/>

Which output data from the list, rather I want code needs to be taken from message.properties as comma separated

Obviously I can do it through iterating the list, like this

<g:each in="${command.daysList}" var="day" status="count">
    <g:message code="label.promotion.create.short.${day}"/>
    <g:if test="${count+1 < command.daysList.size()}">, </g:if>
</g:each>

Upvotes: 0

Views: 222

Answers (1)

cfrick
cfrick

Reputation: 37073

there is no shortcut for this. you can use this in your view:

command.dayList.collect{ message(code: "label...${it}") }.join(", ")

Upvotes: 2

Related Questions