@TemplateMethod
Jeremy Chone <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
I am building a Web Framework which will use Freemarker as the
preferred template engine. This WebFramework is heavily based on
annotations, and I am thinking about implementing a annotation way to
register any java methods as a TemplateMethod.
So, the concept will be
public class MyPojoClass{
@TemplateMethod
public String maxString(String orginalString){
//some code
return newString;
}
@TemplateMethod
public String getDataOffset(Date ...){
...
return fancyDateString; // 2 hours ago
}
}
The idea, would be to call something like
configuration.addTemplateMethodsBean(myPojoClass) to register the
@TemplateMethod methods as Freemarker templateMethods. On invocation,
it will make the best possible job on type conversion, allowing the
Java developer to just worry about standard Java type and custom
application types.
Obviously, there could be extra params on the @TemplateMethod. Like
name (to override the function name), namespace to avoid conflict,
....
Anyway, this could be implemented with some TemplateMethodModelEx
proxy (which I will probably do), but I just wanted to share my
thoughts if to know if there is anything along those lines.
Jeremy,
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge