Does/Can StringTemplate support Iterable

150 Views Asked by At

I would like to iterate over a collection of data stored in an arbitrary data structure. The only interface I have is Iterable. Is this possible with StringTemplate?

<source:{e|e.stuff}>



class Source<HasStuff> implements Iterable<HasStuff> {
   // Implementation
}
1

There are 1 best solutions below

0
Sam Harwell On BEST ANSWER

The current release (4.0.7) supports Iterator, but not Iterable. For details, see the following method, which returns an Iterator for use in the mapping operation.

https://github.com/antlr/stringtemplate4/blob/4.0.7/src/org/stringtemplate/v4/Interpreter.java#L1112-L1132