[stringtemplate-interest] Renderer "modes"

Micheal J open.zone at virgin.net
Tue Jun 20 19:03:57 PDT 2006


Hi,

> Instead, let's follow what I think you originally posted:
> registering  
> formatter objects as renderers but we expose some properties.  The  
> key efficiency thing here is that the wrapper/formatter can be a  
> singleton now--you don't have to wrap every string in an formatter  
> object.  $name.toUpper$ would be converted to
> 
> r = renderer.get("String");
> r.toUpper(name);

....

> In summary, the syntax is identical but we'd have to modify
> 
> ASTExpr:
> 
> 	protected Object rawGetObjectProperty(StringTemplate
> self, Object o,  
> String propertyName) {...}
> 
> so that it checked for a renderer for o's type before doing anything
> else.  A renderer registered for o's type would take precedence over  
> anything else even if o is a Map or StringTemplate.  This way we can  
> automatically add properties essentially to any type of object.
> 
> How does this sound?  I like it.

+1


This seems like a way out of the long-standing
single-renderer/multiple-formats issue. I remember discussing this issue
last year and favouring attribute-specific renderers. ;-)

Is there likely to be a noticeable cost associated with always having to
check if the 'propertyName' parameter really is a valid (i.e. exisiting)
property on the registered attribute renderer?


Micheal

-----------------------
The best way to contact me is via the list/forum. My time is very limited.



More information about the stringtemplate-interest mailing list