Template Language Reference

ClassGenerator templates use a simple language with a small number of statements. Eventhough the language is restricted, you can accomplish almost anything.

ClassGenerator uses a tag based language, that mixes content and logic. Content to produce and logic for ClassGenerator to parse and execute. It's similar to ASP (Active Server Pages - used in Microsoft's IIS since Windows NT), in fact it's logic is based on ASP scripting (it doesn't use the scripting engine though, just the idea and syntax).

A sample template (a simple one) follows:

##DIRECTIVE START_TAG=<% END_TAG=%>

 

This is just content

Directives start with ## (two hash marks), no white spaces in the beggining

 

            PropertyName    PropertyType

<%FOREACH PROPERTY PROPERTY_TYPE IN PROPERTIES PROPERTIES_TYPES %>

            <%PROPERTY%>           <%PROPERTY_TYPE%>

<%END FOREACH%>

 

 In the sample above, the template is devided in three parts:

  • Directives
  • Content
  • Statements

The later two actually intermix, as content resides between satement tags.

In order to use the above template in ClassGenerator, we also need a database table (Customers table in Northwind database). The database table name will be used to produce the generated file (usually it's the table name itself). The extension of the produced filename is the same as the template filename extension.

So, in our case let's call the template FirstTemplate.test, the produed filename will be Customers.test. The produced file would be as follows:

This is just content

Directives start with ## (double sharp), no white spaces in the beggining

 

 

            PropertyName    PropertyType

            CustomerID           String

            CompanyName           String

            ContactName           String

            ContactTitle           String

            Address           String

            City           String

            Region           String

            PostalCode           String

            Country           String

            Phone           String

            Fax           String

For more information you can download the User's Guide.