views:

49

answers:

1

I have a String made up of several Strings seperated by commas. Using StringTemplate, is there an easy way to write a seperate line for each 'value' in this outer String?

For example, I have:

String layers = "ADM,NAV";

and I want to output:

ADM,Y,
NAV,Y,

I suspect the template would look (if it's possible) something like this:

$layers.split(","): {layer | $layer$,Y, }$

Here's a somewhat-possibly related example I found of how write a line for each object in a collection:

<ul>
    $orders: {order|
        <li>Order $order.OrderId$</li>
    }$
</ul>

However, I cannot just build a collection out of the String in my Java code - it must remain a comma-seperated String. Any ideas?

Thanks!

+1  A: 

It is not possible according to the philosophy of StringTemplate: template engine's purpose is to separate representation from business logic. In your case splitting string is business logic and cannot be performed in template.

Jonas