[stringtemplate-interest] ST map improvement

Andrew Goodnough Andrew.Goodnough at wicourts.gov
Wed Jan 4 06:57:59 PST 2006


In my template group file, I've got a type map.
 
opMap ::= [
 "ADD":"ADD",
 "CHANGE":"MODIFY",
 "REMOVE":"DROP",
 default:"UNSUPPORTED_OPERATION"
]
 
In this case a default of "UNSUPPORTED_OPERATION" is fine but there are
other cases where I want the default to just return the key value.  So
if it's not in the map, just give me the original value back.  Something
like:
 
opMap ::= [
 "ADD":"ADD",
 "CHANGE":"MODIFY",
 "REMOVE":"DROP",
 default:key
]
 
or maybe even better:
 
opMap ::= [
 "ADD":"ADD",
 "CHANGE":"MODIFY",
 "REMOVE":"DROP",
 default:<op_key()>  //where op_key() is a defined template
]
 
 
This would make the calling code more readable and concise.  Instead
of:
 
<if(it.operation)><opMap.(it.operation)><else><it.operation><endif>
 
it could be:
 
<opMap.(it.operation)>
 
 
Would this be helpful for anyone else?
 
 
Andy
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20060104/3a4384be/attachment.html


More information about the stringtemplate-interest mailing list