[stringtemplate-interest] Using the "format" option with a template calls

Terence Parr parrt at cs.usfca.edu
Tue Jan 25 11:45:02 PST 2011


Hi. does <(t()); format="upper"> work?
Ter
On Jan 25, 2011, at 12:56 AM, Udo Borkowski wrote:

> While the "format" option work fine with attributes, like in
> 
> 	<attr;format="upper">
> 
> it does not seem to work when used together with template invocations, like:
> 
> 	<t();format="upper">
> 
> I don't know if this is intended (e.g. because of performance reasons) or a bug. I personally would like to have the format option also work in the latter situation. E.g. when I "refactor" my templates it happens data once stored in an attribute moves into a template. This was not possible when the "format" option is used.
> 
> 
> I am currently working around this by using a custom ObjectModelAdapter for ST, using this code:
> 
> 	public Object getProperty(ST self, Object o, Object property,
> 			String propertyName) throws STNoSuchPropertyException {
> 		if ("render".equals(propertyName) && (o instanceof ST)) {
> 			return ((ST) o).render();
> 		}
> 		return super.getProperty(self, o, property, propertyName);
> 	}
> 
> This way the above example looks like this:
> 
> 	<t().render;format="upper">
> 
> While this works fine I am still wondering if the "format" options should also work for the simple template call, too.
> 
> What do you think?
> 
> Udo
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list