[stringtemplate-interest] Problem with C# dictionaries
brian.kejser at protexis.com
brian.kejser at protexis.com
Tue Oct 31 08:51:49 PST 2006
Hi
Thanks. I understand what's going on now.
I don't agree with the implementation of this aspect of the string
template library. I believe the 'it' notation should always refer back to
the original object and not some deviation of the object. In order words,
I feel the following two templates should always render the same output?
$value.something$
$value:{$it.something$}$
In my opinion, this implementation contradicts the philosophy of string
template. That is, complexity and obfuscation are introduced into the
string template library for no apparent reason.
I would appreciate any comments on the above statements.
I am grateful for the work done on the string template library so please
dont mistake my comments as an attack on the project members.
Thank you
-----Original Message-----
From: "Kunle Odutola" <Kunle_Odutola at hotmail.com>
Sent: Mon, October 30, 2006 8:20
To: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Problem with C# dictionaries
Hi Brian,
> Here's the C# code:
> Dictionary<string, string> dictionary = new Dictionary<string, string>();
> dictionary.Add("one", "testing");
> dictionary.Add("two", "more testing");
> stringTemplate.SetAttribute("value", dictionary);
>
> Here's the first string template:
>
> Start
> One: $value.one$
> Two: $value.two$
> End
>
> Here's its output:
>
> Start
> One: testing
> Two: more testing
> End
$value$ is the dictionary. And ST# supports accessing the keys ("one" and
"two" in this case) as though they were attributes of the dictionary.
> Here's the second string template:
>
> Start
> $value:{One: $it.one$
> Two: $it.two$};separator="\r\n"$
> End
>
> Here's its output:
>
> Start
> One:
> Two:
> One:
> Two:
> End
>
> Shouldn't the outputs be the same? Am I doing something wrong or is this a
> bug?
$value$ is still the dictionary. Template application returns a list of the
values in the dictionary i.e. ["testing", "more testing"]. So, $it$ would be
"testing" then "more testing" the second time. Strings don't have the
attributes 'one' or 'two'.
Kunle
_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list