[antlr-interest] StringTemplate "reflection" enhancement

matthew ford Matthew.Ford at forward.com.au
Sat Sep 25 15:21:59 PDT 2004


Hi Ter,
I think my data interface definition  file in WebStringTemplates
(www.webstringtemplates.org) addresses this issue.
It uses reflection to output all attributes and their string values in an
html page as Data Definitions
This output can be produced by setting a special control attribute to
"true".
By the way you need a recursion limit to prevent loops, my default is 3
levels but can be modified by setting
another special control attribute to the level required.
My control attributes all include a .  (dot)  and are not valid attributes
for use in a template so there is no
name space clashes.

I have attached a sample output which also shows all the data filters
defined and which one is used to filter each
attribute before supplying it for use in the template.
(http://www.forward.com.au/webstringtemplates/manual/samples/bookstore3Filte
rs.html)

These data interface definition files can also be read back in to initialize
attributes.
See the detailed docs and extensive examples on the web site for more
details.
matthew

P.S. as the name suggests WebStringTemplates was inspired by Ter'
StringTemplates but is biased towards
(but not restricted to) webpages.

----- Original Message ----- 
From: "Terence Parr" <parrt at cs.usfca.edu>
To: <antlr-interest at yahoogroups.com>
Sent: Sunday, September 26, 2004 6:31 AM
Subject: [antlr-interest] StringTemplate "reflection" enhancement


> Howdy,
>
> When debugging templates particularly for web pages with lots of nested
> templates, printing out the list of attributes you've set with
> setAttribute() is pretty handy.  You could, for example, display the
> contents of all attributes at the bottom of a web page if in "debug"
> mode.  So if you had set two attributes title (a simple string) and
> user (a user-defined object), you might want this info:
>
> Name: title
> Type: java.lang.String
>
> Name: user
> Type: org.foo.MyUser
> Properties: name, email, address, phone
>
> It shows the incoming data not the references in the template.
>
> Seems like this can be easily had by allowing templates to access the
> list of attribute name/value pairs via a reflection method.  We'd want
> this to be on-demand rather than computing a set of reflection
> descriptors each time.  Rather than make a special attribute, we should
> make it something like <self.attributes> which will on demand (when
> rendered) call getAttributes() on "self" (the template object).
>
> <self.attributes> would return not the raw attribute data, but a
> reflection object that describes the key/value pair.  That reflection
> object would let you say:
>
> <self.attributes:{Name: <it.name> Type: <it.type.name> Properties:
> <it.properties>}>
>
> Further you want to be able to be able to recursively walk down to
> embedded templates and get those attributes.  You'd probably want a
> flattened list of all attributes for any particular page.  Perhaps that
> requires <self.embedded> or <self.children> so you can use
> StringTemplate to walk down to those templates. :)
>
> All I have to do is set "self" to be a predefined attribute pointing to
> the surrounding template "this" pointer and all this will just work.
> <self.name> etc... will just work as they are getXXX methods already
> defined.
>
> Hmm...anybody have any suggestions or problems with this approach?
>
> 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!
>
>
>
>
>
>
> 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/
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040926/9c0c09bd/bookstore_stDataInterfaceDefinition.htm


More information about the antlr-interest mailing list