[stringtemplate-interest] Dynamic property names in StringTemplate v3.2 for .Net

Magdalin, Vlad Vladimir_Magdalin at intuit.com
Fri Nov 20 15:06:48 PST 2009


Hi Sam,

 

I've been evaluating your build of ST 3.2 for .Net, and have ran into
only one issue so far where it doesn't seem to be backwards compatible
with the 3.1 version.

 

Let's say I have a C# object with two properties Prop1 and Prop2, and I
pass the object to the template as view data as "myObj".

 

With the 3.1 version of ST, I was able to do something like this:

 

Template1.st

---------------------------------------

This is something from Template2: $Template2(myObj = myObj,
property="Prop1")$

---------------------------------------

 

Template2.st

---------------------------------------

The value of $property$ for this object is: $myObj.(property)$

---------------------------------------

 

The rendered output would include the actual value of the Prop1 property
of the myObj passed to ViewData.  However, in ST 3.2 this doesn't seem
to work at all - it renders: "The value of Prop1 for this object is: "

 

However, if Template2.st contains $myObj.Prop1$, the value is rendered
as expected, but some of my templates call for this type of indirection
where it's convenient for the view to provide the property name to use.


 

Do you know if this is something that's supported by your port? Looks
like it's documented on the main Java documentation wiki
(http://www.antlr.org/wiki/display/ST/ST+condensed+--+Templates+and+expr
essions in the Expressions section).

 

I appreciate any help you can provide.

 

Thanks,

Vlad

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20091120/0d74a525/attachment.html 


More information about the stringtemplate-interest mailing list