[stringtemplate-interest] template expressiveness
Micheal J
open.zone at virgin.net
Fri May 11 21:14:03 PDT 2007
Hi,
> >> stuff[i] gets element at index "i". If "i" is not an integer, an
> >> exception is thrown. Lists can only be indexed by integers, so
> >> where did you get the idea I was asking for
> randomfunction(randomarg)?
> >>
> >
> > Because that is the equivalent of calling stuff.index(i)
> >
> It is equivalent to calling "((List)stuff).get(i)", which is
> not at all arbitrary.
Where would the value of 'i' come from?. Another attribute?. A literal that
is part of the template?.
I'm having a hard time understanding how indexed access increases
expressiveness over property access.
> >> If ST could curry, then it would work...
> >> $stuff:row(color="red"), row(color="blue")$
> >>
> >
> > Ah! That doesn't work! crap. added as a bug:
> >
> > http://www.antlr.org:8888/browse/ST-24
> >
> I didn't realize that was supposed to work! I saw your other
> email that
> it actually does work. This is going to help an enormous
> amount! I don't
> believe this is documented, though it is not impossible that
> I missed it.
It's in a section titled "Applying Alternating Templates To Multi-Valued
Attributes" in the ST manual:
http://antlr.org/wiki/display/ST/StringTemplate+3.0+Printable+Documentation
> I'm not yet sure if what I want is the templates to become a program.
> Without state, problems need to be solved with special
> handling, such as
> the round-robin template application. When the controller doesn't
> provide the data in quite the needed format for display with
> ST, there
> seems there is little else to do except refactor the controller.
Or use a view-specific data formatter/renderer.
> I wonder if a set of templates could provide a Java layer between the
> controller and the templates. The layer could munge the attributes in
> whatever complex ways the set of templates require. This
> seems quite a
> bit less bad than introducing programming inside templates. Maybe it
> could also provide attribute renderers? I have always felt
> funny writing
> an attribute renderer in Java.
Attribute formatting/rendering could be improved in ST. There have been a
few discussions about this in the past.
Micheal
More information about the stringtemplate-interest
mailing list