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

Mike Goodwin mike.goodwin at cantab.net
Wed Nov 3 14:53:25 PDT 2010


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.

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).

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.

- mike


On Wed, Nov 3, 2010 at 8:51 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> Hi Mike. quick question/thought.  Are you expecting indent expr to be evaluated for every iteration?  ST tries to avoid that and does indent once before iteration starts.
>
> Ter


More information about the stringtemplate-interest mailing list