Last week I committed a few extensions to Delphi Razor, the open source server side HTML scripting engine tied to Delphi and part of my overall Delphi Relax framework.

If you've never heard about it, Delphi Relax is a (feature-limited) clone of the ASP.NET Razor syntax to define dynamic HTML pages on a server. In case of Delphi, I use this approach in my DataSnap REST applications, but it can be used also in a plain WebBroker application. The RelaxProcessor component, in fact, replaces the PageProducer, offering a very significative extension.

Basically you create your HTML and use the @ notation for extra processing. At the core, you use @object.property to read a property of a Delphi object registered in the processor (almost like you refer to an object in a LiveBinding expression). You can also use @dataset.field to access a field value. There is support for template files inclusion, for partial HTML snippets, for permissions checks, and other architectural elements. But all of this hasn't changed significantly.

The recent extensions (mostly done with the input of Marco Mottadelli) relate to the conditional and loops. If @if statement can now be nested in a loop and can have loops nested inside its code block. The @foreach statement allows full nesting. The original notation was @foreach list-or-dataset and you'd refer to the individual object or record with the @loop notation. This couldn't work with nesting, so we introduced loop variables, like @foreach (item in list) and you refer to each object as @item.

With these extensions you can navigate through a master/detail dataset structure or a nested list of objects and generate some rather complex HTML output. The official documentation is still not updated, but you can find the core features, component properties... and the actual source code at  http://code.marcocantu.com/p/delphirelax/

PS. I'll have to move to different hosting some time in the future, hope I'll be able to keep the same URL!