[stringtemplate-interest] if-condition in subtemplates
Terence Parr
parrt at cs.usfca.edu
Fri Aug 22 11:06:05 PDT 2008
On Aug 22, 2008, at 5:43 AM, Sindre Svendby wrote:
> Hi, I having problems with if-condition in subtemplate's (template's
> that invokes other template's)
>
> Imagine I _dont_ have a var called nVar and call firstTemplate:
>
> ----
> group templ;
>
> firstTemplate() ::= <<
> $if(!nVar)$
> $subTempl(...)$
> $endif$
>>>
are you sure nVar is not in the parameter list for firstTemplate?
>
> subTempl() ::= <<
> $if(!nVar)$ <--- Reporting
> java.util.NoSuchElementException: no such attribute: nVar in template
> context
> ..whatever..
> $endif$
>>>
> ----
>
> In the StringTemplate Documentation it stand "IF actions test the
> presence or absence of an attribute unless the object is a Boolean, in
> which case it tests the attribute for true/false."
>
> Is this error intentional? Is there any work-arounds, or have I just
> no clue about what I'm doing :)
> I have this problem with StringTemplate Group Files.
Group files enforce attribute definitions whereas template files
don't. Can't ref an attr that doesn't exist.
ter
More information about the stringtemplate-interest
mailing list