[stringtemplate-interest] Managing "type specific" subtemplates

Nathan Ward nward at resqsoft.com
Tue Dec 9 10:55:50 PST 2008


> Sure. or even just set an attribute to the template name and then use  
(name)().

That only works if there is only one case in the templates where there are
type specific subtemplates. I am ending up with several templates that type
specific and are referenced in various other templates. Hence, looks like
the way to go is a simple template map. There doesn't seem to be much other
choice with in StringTemplate, but I think this is fine. I'm basically using
a template map to implement a "case/switch" construct, but I very much
appreciate that StringTemplate enforces separation between model and view.
So, this is a small price to pay.

   Nathan

-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu] 
Sent: Monday, December 08, 2008 1:58 PM
To: Nathan Ward
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Managing "type specific" subtemplates


On Dec 1, 2008, at 12:45 PM, Nathan Ward wrote:

> Any suggestions for how to handle case where a different subtemplate  
> should be used depending on the type of a given model object? Is it  
> reasonable to use a Map to determine the subtemplate to use for this  
> type of situation?

Sure. or even just set an attribute to the template name and then use  
(name)().

Ter




More information about the stringtemplate-interest mailing list