[stringtemplate-interest] Separator definition

Terence Parr parrt at cs.usfca.edu
Tue May 24 17:22:42 PDT 2005


On May 18, 2005, at 7:26 AM, <ilia at obnovlenie.ru>  
<ilia at obnovlenie.ru> wrote:
> I Keep on exploring StringTemplate in various web-related use cases.
>
> Hopefully you'd excuse me for intensive questioning :)

I appreciate it! :)  keep 'em coming!

> Imagine I have to output a table with search results.
> Every search result occupies a single row.
>
> Rows are separated with a large construct like:
> <tr>
>     <td colspan=".." bgcolor=".. changing colors grey-white ...">
>         ....some design here ....
>     </td>
> </tr>
>
> In standard templates that's easy
> {foreach results}
> Result row
> {if not last result}
> Separator row
> {/if}
> {/foreach}
>
> How do I code such thing in StringTemplate?
> I can't even check whether an element is last in list.
>
> Only the way I see is to point at another template in "separator"...
> But such template must be declared separately from the main body,  
> while it
> should be inlined in fact,
> so that way will not do...
>
> Any nice inlining solution ?

I was just informed that while separator=template() works separator= 
{...} does not!  I'm fixing in next release.

Sorry!

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com



More information about the stringtemplate-interest mailing list