views:

132

answers:

1

Is there a template engine for scripted code generation like Apache Velocity or Freemarker (see examples below) which I can use in Delphi applications? (not in the IDE - I am not lookig for a OTA based solution, or Delphi code templates)

The template engine would bind Delphi objects to a template and replace the script variables, and execute iterations / conditions based on values in the objects. Templates can be nested (call other templates).

A typical use case would be the dynamic generation of HTML code, but also work for Delphi code generators.

Velocity example:

<HTML>
<BODY>
Hello $customer.Name!
<table>
#foreach( $mud in $mudsOnSpecial )
   #if ( $customer.hasPurchased($mud) )
      <tr>
        <td>
          $flogger.getPromo( $mud )
        </td>
      </tr>
   #end
#end
</table>

Freemarker example:

<html>
<head>
  <title>Welcome!</title>
</head>
<body>
  <h1>Welcome ${user}!</h1>
  <p>Our latest product:
  <a href="${latestProduct.url}">${latestProduct.name}</a>!
</body>
</html>  

Other Template Engines which are similar to what I am looking for are

+1  A: 

Delphi on Rails, hosted at google code, may have something that you can use. http://code.google.com/p/delphionrails/wiki/Getting_Started

Vegar
Thanks for the link! Lua is a scripting engine, how would I use it to create and run something like the example HTML templates in my question?
mjustin
I have not used it my self, but the examples showed what I thought you where after. All code is available from goole code, so you should download and start digging to see if it is possible to reuse some of it or learn something to make your own solution.
Vegar