[stringtemplate-interest] Maps not behaving as I thought...
Terence Parr
parrt at cs.usfca.edu
Wed Jun 24 14:33:47 PDT 2009
That should work; does in Java version anyway. which version of ST#
are you using?
Ter
On Jun 24, 2009, at 2:01 PM, Thomas Gagne wrote:
> First, thank you, Terence, for pointing me to that document. I
> discovered StringTemplate has something approximate to lambdas!
>
> So the following method, then, does not do as I expect.
>
> [TestMethod]
> public void mapTemplateTest()
> {
> var template = new Antlr.StringTemplate.StringTemplate(@"
> <aMap.keys:{k| <k> maps to <aMap.(k)>}>.
> ");
>
> var aMap = new Dictionary<string, string>();
> aMap.Add("1", "one");
> aMap.Add("2", "two");
>
> template.SetAttribute("aMap", aMap);
> FileLogger.LogMessage(template.ToString());
> }
>
> So the following method, then, does not do as I expect. Instead it
> prints, “<aMap.keys:{k| <k> maps to <aMap.(k)>}>.”
>
> I’m missing something, obviously.
>
>
> From: Terence Parr [mailto:parrt at cs.usfca.edu]
> Sent: Wednesday, June 24, 2009 2:22 PM
> To: Thomas Gagne
> Cc: stringtemplate-interest at antlr.org
> Subject: Re: [stringtemplate-interest] I was expecting to see a
> mechanism for looping or repeating...
>
> there is an exact solution to this problem in the enforcing model-
> view separation paper.
> T
> On Jun 24, 2009, at 11:17 AM, Thomas Gagne wrote:
>
>
> Perhaps I’m unsure if I’m seeing it but not understanding it.
>
> I want to generate an HTML table. I’ll know ahead of time what its
> width will be, but not how many rows there’ll be.
>
> <table>
> <tr><td>description</td><td>Amount</td></tr>
> <tr><td>$description$</td><td>$amount</td></tr>
> </table>
>
> The third row I will want to repeat for each data row I retrieve.
> Does StringTemplate have a way of doing this or have I misestimated
> its practical applications?
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090624/0d471d3e/attachment.html
More information about the stringtemplate-interest
mailing list