[stringtemplate-interest] template existence testing
Zenaan Harkness
zen at freedbms.net
Sat Mar 29 05:43:30 PDT 2008
Hi, I've come across a feature which I would find useful:
It might sound odd, but I would like to be able to, within an <if(...)>
block, test for the existence of a specific template name.
I need to provide template-level specialization of getter/setter method
bodies, and I'd like the template name to be tested for automatically in
the if block, so that a default method body is used normally, and the
specialization is used otherwise.
It is possible to put a boolean in the Model, but that would violate my
MVC: specializations depend purely on the specific template being used.
The model simply should not know or care whether there is an attribute
method body specialization - it is a view specific thing.
The st code looks like this (attribute "a" is the property/ model
attribute which I am rendering in the template as a getter method):
<if( st_exists("att_"+a.attributeName) )>
// we have a specialization for this method, include
// attribute-specific specialization code:
<("att_"+a.attributeName)()>
//alternatively:
<({att_<a.attributeName>})()>
<else>
return a.attributeName;
<endif>
Barring the if conditional of course - st_exists("att_"+a.attributeName).
Any ideas about how much effort this might be to implement, and if it's
sensible or not?
Thanks in advance
Zenaan
--
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.
More information about the stringtemplate-interest
mailing list