AW: AW: [stringtemplate-interest] Problems with List and Hashesrevisited REAL MAIL

Kunle Odutola Kunle_Odutola at hotmail.com
Tue May 30 12:11:48 PDT 2006


> Hello Kunle,

Hi,

Quick reply. Quite busy currently:

> a)
> Am I right in thinking that templates without formal arguments
>
> SomeTemplate() ::= << Output=$it.something$ >>
> can only be invoked as  $SomeData:SomeTemplate()$
> never as $SomeTemplate(SomeData)$
> (I get: "template anotherOutput must have exactly one formal
> arg in template context [..Context..]")

Yes. The long-hand version is $SomeTemplate(parameterName=SomeData)$.

> b)
> Should this template work? (It always crashes on me because
> of stack-overflow)
>
> RecursiveOut(Daten) ::= << $Daten:RecursiveOut();separator=","$ >>
> As both classes in my data-structure (AttributeHash and AttributeList)
> are IEnumerable it should strip away one layer at a time, shouldn't it?

No. The recursion has no terminating condition.

> I can't do that because I don't necessarily know in advance if an
> attribute will be single or multi-valued.
> Therefore it has to be the Data:Template() Syntax.
>
> I solved this (for the time being) by putting any AttributeHash
> (even single ones) into an AttributeList.
> I hope this won't have any ugly side-effects

Quick thought, strings have a .Length while Lists have a .Count. If these
are the only options at this level:

$if(param.Length)
   $! it's a string !$
$else$
   $! else it's not !$
$endif$


Kunle


More information about the stringtemplate-interest mailing list