Sharing Common Code
CodeSmith offers several ways to share common code between templates:
- You can place utility functions in a custom template class and reference it in the Inherits attribute of the CodeTemplate directive.
- You can base templates on a common template class by using code-behind files.
- You can compile common functions into an assembly, and reference the assembly using an Assembly directive.
- You can place common functions into a source code file, and reference the file using an Assembly directive.
- You can use sub-templates to share code between templates.
- You can place common code in a separate source file and use anÂ
include statement to pull it directly into your template.