[stringtemplate-interest] (c#) problem with separator clause
Grzegorz Danowski
gdn at poczta.onet.pl
Sun Jun 24 17:29:09 PDT 2007
Thanks very much for your explanations!
Regards,
Gregory
-----Original Message-----
From: John Snyders [mailto:jjsnyders at rcn.com]
Sent: Sunday, June 24, 2007 3:43 AM
To: GDN
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] (c#) problem with separator clause
I use Java but this problem is with how you defined your template not the C#
implementation.
Using STST to demonstrate:
gdn.js
{ Customers: [
{ CustomerName: "Martha" },
{ CustomerName: "Agnes" },
{ CustomerName: "Margaret" }] }
gdn.st:
Your example
$Customers:{$it.CustomerName; separator="|"$}$ What you intended
$Customers:{$it.CustomerName$}; separator="|"$
stst gdn gdn.js
Your example
MarthaAgnesMargaret
What you intended
Martha|Agnes|Margaret
In the first example the separator option is applied to the scalar value of
it.CustomerName. Because it is not a list the separator does nothing.
It is the same as $Customers:{$it.CustomerName$}$ The separator option needs
to be applied to lists. This is why the second case works.
The case you tried with List<String> was not equivalent.
$Customers; separator="|"$ is the same as $Customers: {$it$}; separator="|"$
not
$Customers: {$it; separator="|"$}$
Hope this helps explain how StringTemplate works -John
More information about the stringtemplate-interest
mailing list