[stringtemplate-interest] Does StringTemplate support components?

Adam Bennett adamb at videx.com
Thu Dec 21 13:54:42 PST 2006


Can I use StringTemplate to create reusable components as can be done with JSP tags?  
   
For example, let's say I want a component that shows a user summary box like you would see beside each users post on an online forum.  The component would use a StringTemplate to generate markup to show the users alias, image, and number of posts.  This formUserBox template would take these values as parameters but first I need some Java code to look at the session and pull the correct values out of the database.  
   
So here I have a parent template that invokes the forumUserBox template:  
   
<html>  
<body>
...
$forumUserBox()$
...
</body>
</html>  
   
But forumUserBox needs attributes that have not been set.  The code that invokes the parent template should not have to worry about providing all the necessary parameters - (separation of concerns).
   
Custom JSP tags allow me to do this but they are inside out.  Is my desire "unclean"?  It does not seem so to me because the view and model are still clearly separated by using a parameterized StringTemplate to generate the actual markup.  What I need is some sort of processing hook.  Before the parent template invokes the forumUserBox template I need it to call some java code so I can provide the necessary attributes.  
   
Thanks much.  
- Adam B


More information about the stringtemplate-interest mailing list