October 6, 2012

Delphi Razor Extensions

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.

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!





 

5 Comments

Delphi Razor Extensions 

Thanks Marco.

Incidentally, is there anywhere we can ask questions
or have discussions regarding this framework? It's
really interesting.

Rob
Comment by Robert H on October 7, 03:20

Delphi Razor Extensions 

 The best way to discuss the framework is to send me email... Or 
post to a forum, and let me know by email...

-marco
Comment by Marco Cantu [http://www.marcocantu.com] on October 7, 04:51

Delphi Razor Extensions 

 The best way to discuss the framework is to send me email... Or 
post to a forum, and let me know by email...

-marco
Comment by Marco Cantu [http://www.marcocantu.com] on October 7, 04:51

Delphi Razor Extensions 

 The link to the repository is dead are you still working on this?
Comment by Steve Sinclair on December 21, 08:46

Delphi Razor Extensions 

Steve,
  code is still under development internally, but the repository was 
migrated and it is not not published on the new system, pending some 
changes in code and organization...
Comment by Marco Cantu [http://www.marcocantu.com] on December 23, 11:39


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.