Question

I am trying to call a template, passing as a parameter the result of calling another template but I can't seem to get it to work. Here's a narrow-down example:

The following template group in a file:

echo(foo) ::="<foo>"
boo() ::= << <echo("zoo")> >>

When called with the following Java code:

STGroup stg = new STGroupFile("thefile.stg");
ST boo = stg.getInstanceOf("boo");
System.out.println(boo.render());

produces zoo as expected.

However, when I try to replace the "zoo" literal with a template that return the same, ST complains during parsing:

doesn't work:

echo(foo) ::="<foo>"
zoo() ::= "zoo"
boo() ::= << <echo( <zoo()>  )> >>
Was it helpful?

Solution

instead of:

boo() ::= << <echo( <zoo()> )> >>

use:

boo() ::= << <echo(zoo())> >>

It appears that the < > need only be used once where the outer template is called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top