(Re)introducing CF Template
It has been a while since I generated code, but I've dusted off CF Template and put it up on RIA Forge. As I say at the project:
Why use XSLT or Velocity when ColdFusion already has a much more powerful and extensible templating language built in?
CFTemplate is a templating language built on ColdFusion that allows you to use the power of ColdFusion to generate anything from documentation to ColdFusion code (or Ruby, Java, XML . . .). It allows you to use any type of data (recordset, iterating business object, XML, etc.) and any valid ColdFusion code within your templates.
For generation time tags just replace < with <<, > with >> and for generation time variables just replace # with % (and as with # signs, if you need a real % sign, just escape it by putting %%).
CF Template is a single cfc that just takes a template filepath, a destination filepath, a scratchpad filepath (for performing the transformation) and metadata (any data type - object, struct, array, XML, etc.) and performs the transformation. Simple, but very useful.
This can be used on its own or as part of cfgen for a complete application generation solution.
I have included a simple example in the samples directory and will be updating this over time. The files are available via subversion. Just comment below if any questions.
If you're looking for a complete generation solution with support for iteration and orchestration to generate complete apps, that'll be cf gen which I'll get up some time this week.
This is a 0.1 release. As I play with code gen again over the next couple of weeks, I'll probably clean up things like the extra whitespace created in the templates and I may refactor the code to make it a little more elegant. I know you have to pass a bunch of parameters to call cf template, but that keeps it flexible and allows for it to be saved as a singleton with multiple generators using it at the same time with different directories - it's meant to be wrapped with a real generator like cfgen anyway, so you wouldn't really use it without wrapping for any more than proof of concept.





There are no comments for this entry.
[Add Comment]