Writing your first template
Running templates that others have written is the first step with CodeSmith Generator. To get the full benefit of Generator in your day-to-day work, you'll write your own templates. In this tutorial you write a template from start to finish. It generates an AssemblyInfo.cs file for a C# project.
Steps
- Spot the need: find a repetitive task worth generating.
- Create the template: add the CodeTemplate directive.
- Start with the result: decide which parts of the output are static, calculated or supplied by the user.
- Add static content: paste the finished output into the template.
- Make the content dynamic: calculate values with expressions.
- Add template properties: declare the values the user supplies.
- Use properties in the template: insert property values into the output.
- Generate code: run the template.
Next: Spot the need