Advanced template syntax
Once your templates grow beyond a single file, these techniques help you organize, reuse and debug them.
| Page | What you learn |
|---|---|
| Understanding the code-behind model | Move template code into a separate source file. |
| Referencing assemblies | Use the Assembly directive to reference a compiled assembly or compile a source file with the template. |
| Importing namespaces | Use the Import directive so that you don't have to fully qualify type names. |
| Including external files | Insert another file's contents into a template with an include statement. |
| Sharing common code | Compare the ways to reuse code across templates. |
| Debugging templates | Step through template code in a debugger, write trace output and view the compiled source. |
| Using master templates | Register, configure and render sub-templates from a master template. |
| Writing to multiple outputs | Send the same output to several destinations at once. |
Next, learn where your templates' input can come from in Driving templates with metadata.