[stringtemplate-interest] Size of a collection

Mohamed Mansour m0 at campusinteractive.com
Thu Jul 24 07:49:28 PDT 2008


Hello,

I am passing in a Vector<MyObject> to the template, and I would like to find
the size of that Vector.

Vector<MyObject> result = getMyItems();
tpl.assign("items", result);

My Template File has the following:

Records
--------
$items:{u|"$u.name;format="uppercase"$"
}$


Which will print out something like:

Records
--------
"TUCCINO JERRY"
"BILL SMITH"
"TOM JERRY"

I would like it find the size of the collection being passed in therefore 3
will show.

3 Records
--------
 "TUCCINO JERRY"
"BILL SMITH"
"TOM JERRY"

So is that possible in StringTemplate? Or I should create another template
stating the size of the collection? like
tpl.assign("itemsSize", result.size());


Thanks!

Another size question: Does StringTemplate allow multiple formatters? In the
above case, I just did $u.name;format="uppercase"$, what if we need more
than one formatter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080724/01f96405/attachment.html 


More information about the stringtemplate-interest mailing list