[stringtemplate-interest] Separation of View and Biz Logic

John Snyders jjsnyders at rcn.com
Wed May 16 05:33:12 PDT 2007


What you describe is not unreasonable but with newer builds of ST there 
is a better option. The format option. It is not yet documented except 
in this thread
http://www.antlr.org:8080/pipermail/stringtemplate-interest/2006-December/000847.html
This reminds me that I should document it soon.
-John


Bill Venners wrote:
> Hi All,
>
> We are migrating some velocity templates to ST, and in the velocity  
> templates we had been calling some static utility methods to do  
> things like uppercase the first char, lowercase the first cahr  
> transform a camel case word (like employeeStartDate) into a constant  
> form (like EMPLOYEE_START_DATE)--things like that. Rather than make  
> separate variable for each form, we were thinking of making a utility  
> class whose instances take a String. Then there are get methods for  
> each of the permutations, like getWithFirstUpper(), getWithFirstLower 
> (), getInCamelCase(), getInConstantForm(), etc. So it could be  
> accessed inside an ST template with employeeStartDate.withFirstUpper  
> or employeeStartDate.inConstantForm. The toString method on this  
> object would just return the String passed to the constructor. We  
> would encapsulate relevant String variables inside instances of this  
> class, then pass those to the template instead of the raw Strings.
>
> This seems perfectly reasonable way to do this, but I wanted to check  
> whether it violated anyone's sense of strict separation between view  
> and biz logic.
>
> Thanks.
>
> Bill
> ----
> Bill Venners
> President
> Artima, Inc.
> http://www.artima.com
>
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>   


More information about the stringtemplate-interest mailing list