One of the problems with using Razor, T4 and other text templating engines that were primarily designed to integrate with specific tools or technologies is that once you extract them from their environment they lose their identity. That is, once removed from the pipeline in which they were designed to run they no longer have the inputs/outputs that made them functional in their native environment. So it follows that once removed from their original environment you need a harness - a new environment - in which they can function without the template itself having to provide the services provided by the pipeline from which they were extracted.
Csx is a "template runner" for Razor and Nmp (.NET Macro Processor) text templates. It's currently a command line program that wraps the templating engines in an environment where you create instances of the data required by your templates and "feed" it to them in a generic way.
From the __Readme First.txt:
Csx (pronounced "cee-es-ex" - or if you prefer: "ceex") is a small build tool that is focused on two things:
- Process text templates with the Razor Template Engine or the Nmp Macro Processor.
- Building small C# projects.
The current build is a 0.1.0.xx release that is used in production by the developer (me) but is far (far) from complete.
Some of the features are:
- Dependency builds of Csx projects, or MSBuild projects.
- Text templating using the Razor (v1.0) templating engine.
- Text templating using the Nmp templating engine (it’s a macro processor).
- Instantiate a single instance of a .NET class and pass it to a template for processing.
- Iterated over collections of .NET objects and invoke a template for each object instance, saving the output to a single or multiple output files.
- Separation of templates from the data they process and the location of their output.
- Not so good errors.
- Not so good documentation.
- Not open source (at this time).
Note: Csx runs under .NET 4.0.
Csx if free to use, but please read the license.rtf or license.txt file for what that means.
Csx Template Runner