I have been working hard recently to release the version 0.2 (Maybe I should call it 2.0
) of Cambridge Template Engine. This upcoming new release of my template engine has new features, a lot of bug fixes and performance improvements.
First of all let me write about what is new in this release. Perhaps the most important change in 0.2 is the new expression language architecture. In version 0.1 you were able to use only the built in custom expression language. I realized that there are other good expression language alternatives for Java that are very popular which could be used with Cambridge. With release 0.2, Cambridge not only supports the built-in simple expression language but also allows you to use either MVEL or OGNL. You can also integrate other expression languages by only implementing two simple interfaces.
Another big new feature is template inheritance. Cambridge templates now can extend other templates and the child template can override parent templates tags. Here is an example of how it works:
Parent template: (skeleton.html)
<html>
<head><title>${title}</title>
<body>
<div class="mainMenu">
<div id="menuElements"></div>
</div>
<div id="main"></div>
</body>
</html>
Child template:
<!--$extends "skeleton.html"-->
<div id="menuElements">
<ul>
<li>Home</li>
<li>Products</li>
<li>About Us</li>
<li>Contact</li>
</ul>
</div>
<div id="main">Main Content</div>
So what happens here is that every element that you define in the child template overrides the element with the same id of the parent element. Unlimited levels of inheritance is supported and this doesn’t cost you any performance penalty whatsoever.
A nice addition to the templates are true if/elseif/else conditional blocks. In version 0.1, all you could add as a conditional tag behavior was an if statement. Now you can do the following:
<div a:if="speed > 80">Fast</div> <div a:elseif="speed > 40">Not so fast</div> <div a:else>Slow</div>
The only trick here is that the elements of a conditional block can be only separated by white space. No other tag or text node can come between nodes marked with conditional tag behaviors.
A nice addition to the supported web frameworks in version 0.2 is the Play Framework. Now if you put cambridge-playframework.jar and cambridge-core.jar into your classpath, you can start using Cambridge as your template engine in play framework. My benchmark tests show 2.5 times faster page rendering times compared to Play Framework’s own template engine! Play framework support is built with the new extension point API which allows you to alter tokenizing and parsing behavior of template parser for custom code blocks. If you want to decide how template blocks starting with %{ and }% are handled for instance, you can create an extension point for that.
Support for Spring MVC and Struts 2.0 are also work in progress for version 0.2.
The core functionality has reached a feature freeze and there doesn’t seem to be any show stopper bug for the 0.2 release right now. I released a beta today and after Spring MVC and Struts 2.0 integrations are complete and the documentation is updated, I will release 0.2.

This is so cool… make my playframework project so much easier.
waiting for major release