What's coming next? Text templating improvements.

Stuart has a great post on what's around the corner in DSL Tools world.

Particularly important from a planning perspective is that our next release will require users to move to Visual Studio 2005 Beta 2 (and of course this means that we'll release after that does).

He mentions that one focus we're planning for the next release is improvements to our text templating technology.

Text templates are the glue that allow writing of ASP-like template files to generate code, reports, other models or any other kind of text file.  Whereas ASP page templates typically use a database or some business objects as their data source, our templates typically use a model file and the accompanying API generated by our tools as their data source.

A key point is that this system works with models created in both of the DSLs that ship as part of the DSL Tools (the Domain Model Designer and the Designer Definition xml file) and in exactly the same way with models created in the DSL designers that you build yourself.

We actually quietly added some functionality to the templating system in our March release.
I'm using the string <delim> in the text below as a substitute for angle-bracket percent as .Text doesn't like the literals, no doubt guarding against an injection attack.

You can now declare functions for use elsewhere in the template using a new type of code block with the delimiters <delim>!  </delim>, for example:

<delim>!
private static bool CalculateSomeValueRecursively( YourModelElement root )
{
    // Do funky recursive stuff
    return true;
}
</delim>

Right now, there are a couple of limitations:
Functions you declare have to be static - we'll be lifting this restriction in a future release.
You can only have one <delim>!  </delim> block and it must come after all directives and before the rest of the template. You can declare as many functions as you like in this block though.

You're then free to call this function from any regular <delim> </delim> or <delim># </delim> block.  This functionality is pretty useful for a couple of things.
Firstly, it can tidy up your templates no end by removing repetitive code.
It allows you to walk the tree-like structures often found in models using recursion.  While recursion is not always a suitable technique, it is very, very convenient when traversing many models.

Looking ahead, a significant additional facility that we're planning in text templating is to enable a #include mechanism.  This will allow the repetitive code from templates to be squirreled away in a standard place, drastically easing maintenance.

(Sorry for all the updates, but I had a terrible time getting this entry to post)