So I was doing a Freshmeat trawl and came across the usual clutch of content management systems, and JPublish looks pretty good. It uses the Velocity engine, it has a repository abstraction layer and various other nice things. Haven’t tried it (CMSes aren’t the kinds of things I have quick plays with unless the interfaces are particularly spiffy) but it may be worth a look if Java is your bag.
Anyway, one thing that prodded my interest was a mention of a templating methodology called FreeEnergy that was created for PHP and apparently has been adopted for various templating systems in other languages. The key description is apparently in this article by the guy who created it. So I’m expecting something neat and useful, and what do I find? Nested includes. That’s it. Oh, and a big question about how to chain actions and do decent error handling without massive nesting, which shows the author has never heard of exceptions. (So that’s yet another reason to for me to continue my personal vendetta against PHP.)
Let me tell you about a templating feature which I really like and which should be supported in many more web app systems. I first encountered it in an open source e-commerce system called Minivend (now Interchange) and I haven’t seen it anywhere since. The big idea is that you can write some HTML-embedded code to be executed when a user clicks on a link or form, but this code lives in the same file as the link or form to be clicked, as opposed to living in the file targeted by the link.
An example: clicking on a link adds an item to your basket and then takes you back to the front page, in one page load. The code for adding the item lives in the item page, not in the front page or an intermediate page. I like the idea of putting the code for an action as close as possible to the button which activates it. The code lives with the link, not with the destination. (One problem, though, is that the final URL of the link is not the same as the URL for the page you end up at, but if it’s coded correctly, this shouldn’t be too much of a problem, since using the generated link later on should be able to deliver you to the right page without unwanted side-effects. The key’s in the session management.)
You could use it for all kinds of things, but most notably for the kinds of actions that usually require forms rather than links. It’s not exactly revolutionary but, as I say, I haven’t seen it anywhere else and it’s a really nice feature to have. Any system with decent session management should be able to handle it.
Interchange has a bunch of other lovely features too that are applicable to all kinds of web apps, not just shopping, but the interface orients it totally towards e-commerce. Perhaps it might be worth hacking around with to turn it into a generic web app kit?