[stringtemplate-interest] Problem with C# dictionaries
Kunle Odutola
Kunle_Odutola at hotmail.com
Mon Oct 30 08:20:36 PST 2006
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
More information about the stringtemplate-interest
mailing list