views:

109

answers:

6
+1  Q: 

Template engines

Are there any for purposes other than web? e.g. for use in script generators, c++ code generators or other related, generic operations.

Thanks, B

+2  A: 

In Visual Studio there is a templating engine primarily for code generation, called T4.

Here is an entry point for documentation on MSDN.

So, to answer your question, yes they to exist for other purposes than the web.

Oded
A: 

They can generate configuration files.

Puppet and Chef rely on erb templates a lot, for example.

Tobu
+2  A: 

Have a look at http://velocity.apache.org/ or http://nvelocity.sourceforge.net/

Henrik Jepsen
A: 

Yes there are many out there. One that I know of that allows you to generate more templates if you need them is MyGeneration. Another, is you could always build your own xslt template engine then you could build whatever you need. However there are several opensource and commercial code generators.

Joshua Cauble
A: 

E.g. StringTemplates is a Java-based template engine for generating all sorts of text artifacts, and model generator frameworks like openArchitectureWare (or GeneSEZ) use the Expand template engine.

Frank Grimm
A: 

Imatix GSL is the most impressive (and simplest) of the tools that I have encountered. Plus it has been used to generate large amounts of complex code.

Also, lua is a programming language whose initial purpose was data definition, and I have found it to be very capable in this area. So, you define your data in lua and you execute the data definition files (valid lua programs) and you can generate any code from it.

Consider the following model for a C-function in Lua.

> func {    
>     name { "xyz" }
>     parameters { 
>         { name= "x" , type="uint32_t" }  , 
>         { name = "y" , type = "uint32_t"} 
>     }
>
>     ret { type="uint32_t" }
>   
>     psuedocode {      
>        "getLock(lockName)"   ,
>        "getSessionMemory"    ,
>        "addSession"      ,        
>        "releaseLock"              
>     } 
> }
Hassan Syed