Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringTemplate - How to iterate through list of business objects and output simple html? [closed]

I've just started using StringTemplate in my C# project. I went through the documentation, but I can't seem to find a way to implement this simple scenario:

I have a list of simple business objects (let's say Orders) and I want them displayed inside a UL tag inside my html template.

So, my .st template looks like this (pseudo-code):

<html> some text <ul>[Order template]<li>[Order name here]</li>[/Order template]</ul></html>

and I want my output to be:

<html> some text <ul><li>Order 1</li><li>Order 2</li>...</ul></html>

I can't figure out how to make this work using StringTemplate. Any ideas?

like image 373
Alt_Doru Avatar asked May 11 '09 09:05

Alt_Doru


1 Answers

You should use the following syntax:

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

The documentation about this feature is really hard to find, I found some info here (search for the pipe symbol |).

like image 117
Ronald Wildenberg Avatar answered Oct 15 '22 17:10

Ronald Wildenberg