[antlr-interest] StringTemplate naming question
Tiller, Michael (M.M.)
mtiller at ford.com
Wed Jul 14 07:27:55 PDT 2004
Are you guys familiar with TAL, the templating system used in Zope? You
might find it interesting since some very similar ideas are used there.
I recognize that it may be overly specialized for your applications but
I you still might find it interesting to see how they have chosen to
implement similar things. Here is a link:
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx
...I suggest turning the comments off (button near the top). In
addition, I even ran across a Java implementation:
http://webslingerz.com/rossi/jpt/userguide.html
--
Mike
> -----Original Message-----
> From: matthew ford [mailto:Matthew.Ford at forward.com.au]
> Sent: Tuesday, July 13, 2004 6:08 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] StringTemplate naming question
>
> Yes that reservered name has always worried me.
>
> In WebStringTempatesV2 I have introduced the concept of root and
current
> contexts
> The root context is referred to by . (dot)
> the current context is referred to by .. (doubledot)
> Although I handle lists without embedded or sub-templates the concept
can
> still
> be applied to StringTemplates
>
> In WebStringTemplatesV2 instead of
> > $names:{<b>$attr$</b>}$
> where names is a list, you would say
> $[list names] <!-- this sets each item in the names list as the
current
> context one at a time-->
> <b>$[..]</b>
> $[endlist]
>
> where the $[..] returns the current context. I.e the
> current item of the name list being processed.
>
> Applying this to StringTemplates
> > $names:{<b>$attr$</b>}$
> would become
> > $names:{<b>$..$</b>}$
>
> If names had the structure
> firstname, surname
> That is names is a list of maps or beans that contain entries for
> firstname
> and surname
> then
> > $names:{<b>$attr.firstname$ $attr.surname$</b>}$
> would become (under this proposal)
> > $names:{<b>$firstname$ $surname$</b>}$
> because by default attributes are always looked upwithin the current
> context
> $firstname$ is the same as $..firstname$
>
> if you want to lookup an attribute in the root context then you would
use
> > $names:{$.title$ <b>$firstname$ $surname$</b>}$
> where title exists at the top level (the same level as names)
> in $.title$ the leading . (dot) indicates you are accessing the
root
> context not the
> current context.
>
> Applying this to sub-template calls
> gives
> $names:list()$
> where
> the list sub-template contains just
> ${<b>$..$</b>}$
> or
> ${<b>$.$</b>}$
>
> since initially the root and current context are the same within a
> template
> or sub-template
>
> The use of . and .. removes the need for a pre-defined argument name.
> matthew
> ----- Original Message -----
> From: "Terence Parr" <parrt at cs.usfca.edu>
> To: <antlr-interest at yahoogroups.com>
> Sent: Wednesday, July 14, 2004 6:15 AM
> Subject: [antlr-interest] StringTemplate naming question
>
>
> > Howdy...for you StringTemplate users...currently I use $attr$ or
<attr>
> > to refer to the default attribute that iterates over a list. For
> > example,
> >
> > $names:{<b>$attr$</b>}$
> >
> > I'm going to change the name as I don't like attr. How about $it$
(as
> > in "it" or "iterator")? How about $obj$?
> >
> > Thanks,
> > Ter
> > --
> > CS Professor & Grad Director, University of San Francisco
> > Creator, ANTLR Parser Generator, http://www.antlr.org
> > Cofounder, http://www.jguru.com
> > Cofounder, http://www.knowspam.net enjoy email again!
> > Cofounder, http://www.peerscope.com pure link sharing
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list