[stringtemplate-interest] Bug/Problem passing parameters into iteration

Terence Parr parrt at cs.usfca.edu
Wed Nov 3 14:59:31 PDT 2010


On Nov 3, 2010, at 2:53 PM, Mike Goodwin wrote:

> Hi Terrence,
> 
> No that is not the expectation.
> 
> In the expression:         indent=indent+"  "
> 
> My understanding is that StringTemplate is functional so reassignment
> would not be a legal action. I expect that the left hand side 'indent'
> is the name of the value being passed to the next call and so does not
> refer to the indent in the calling scope.

Oh. actually it does lazy eval in case you ref another parameter. 

> 
> What I would dearly like to see as an example is how to create
> something using arbitrary depth recursion, passing in extra
> parameters. A good example, and variation on what I attempted to do
> would be a html contents page with   for indent and section
> numbers (ignoring the fact that css + <ul> would be a better way to do
> the indenting part).

Well, it autoindent happens automatically in ST but I get your point.  BTW, you did turn off the auto indent right?  Else you'll get double.

> If I am honest I really expected it to be a doddle because of the
> functional design of StringTemplate, it is after all just a bit of
> recursion. I tried many variations, but with no success. In the end I
> resorted to using java to create the recursive bit of the html.

I've used recursive templates to walk tree models and such.


Ter


More information about the stringtemplate-interest mailing list