2

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 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.