Inspecting the Template


Let's take a peek behind the scenes at the HashTable.cst template itself. Remember, the template contains the instructions that CodeSmith uses to generate the code. Return to CodeSmith Explorer, but this time right-click on the template and select Edit. This will open the template in CodeSmith Studio, the full-featured IDE that CodeSmith provides for editing templates.

Later on in this help file you can learn more about CodeSmith Studio in detail. For now, just poke around the source code for the template a bit: it's displayed in the main editing area. As you can see, CodeSmith's template language is very similar to ASP.NET. The file starts off with a set of directives, including some that declare the various properties that appear in the template. These properties can be used later in the template by enclosing them in special tokens. For example, the line of code in the template

namespace <%= ClassNamespace %>

instructs CodeSmith to output the literal string "namespace" followed by the value of the ClassNamespace property when it is generating code.

If there's something you don't like about the HashTable template, you can change it here. For example, you might like to add some comments to explain the reason why each interface is included. You can just type these into the template and save your changes to have CodeSmith use the altered template in the future.

Next: Where to Go from Here