[stringtemplate-interest] Simple example of list iteration
Richard Apodaca
rapodaca at metamolecular.com
Wed Feb 29 13:08:51 PST 2012
> though it sounds like there may be something else going on.
I think there is. Please see this post and the accompanying unit tests:
http://www.antlr.org/pipermail/stringtemplate-interest/2012-February/003919.html
https://gist.github.com/1943633
Thanks,
Rich
On Wed, Feb 29, 2012 at 11:27 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
> in v4 there is no implicit it. That means you can simply declare it and it
> will work:
>
> > $items:{it | <li>$it$</li>}$
>
> please try that, though it sounds like there may be something else going
> on.
>
> Ter
> On Feb 29, 2012, at 9:21 AM, Richard Apodaca wrote:
>
> > I'm new to StringTemplate and baffled about how to iterate over a list
> using ST4 in a servlet.
> >
> > Given a List<String> called "items":
> >
> > List<String> items = Arrays.asList("hello", "world");
> > view.set("items", items);
> >
> > I've seen examples claiming this works:
> >
> > <ul>
> > $items:{<li>$it$</li>}$
> > </ul>
> >
> > But I get this error:
> >
> > > anonymous template has 0 arg(s) but mapped across 1 value(s)
> >
> > which was discussed here:
> >
> >
> http://www.antlr.org/pipermail/stringtemplate-interest/2011-February/003064.html
> >
> > Trying the different form suggested above (which I could be
> misinterpreting):
> >
> > $items:{value|$value$}$
> >
> > gives this error:
> >
> > > no such template: /layouts/_sub20
> >
> > I'm setting up the template via the servlet with:
> >
> > STRawGroupDir dir = new STRawGroupDir("/com/foo/views", '$', '$');
> > ST template = dir.getInstanceOf("layouts/application");
> >
> > The "_sub{x}" part in the error increases every time I try to reload my
> page. Any ideas of where this simple thing is going wrong?
> >
> > Thanks,
> > Rich
> >
> > --
> > Richard L. Apodaca
> > Founder and CEO
> > Metamolecular, LLC
> > 8070 La Jolla Shores Drive #464
> > La Jolla, CA 92037
> > 858.658.0860
> >
> > http://metamolecular.com
> >
> > _______________________________________________
> > stringtemplate-interest mailing list
> > stringtemplate-interest at antlr.org
> > http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
--
Richard L. Apodaca
Founder and CEO
Metamolecular, LLC
8070 La Jolla Shores Drive #464
La Jolla, CA 92037
858.658.0860
http://metamolecular.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20120229/cf9a5cd4/attachment.html
More information about the stringtemplate-interest
mailing list