Overview: Insert the Contents of One Template into Another's Assembly Process
You can use the INSERT instruction to tell HotDocs to insert an existing template's contents into the document assembly process of another template (the "parent" template where you add the INSERT instruction).
When (during the parent template's document assembly process), HotDocs encounters the INSERT instruction, HotDocs interrupts the parent assembly to assemble a document from the "child" template. When HotDocs finishes assembling the child document, HotDocs inserts the text of the child document at the location of the INSERT instruction, and then finishes assembling the parent document so that the final output is one seamless document.
This is different from how HotDocs handles the ASSEMBLE instruction.
The INSERT instruction can be particularly useful for inserting content you use over and over again—such as signature blocks, legal headers, and other boilerplate language.
Reasons for inserting contents from one or more templates into another template's document assembly process vary with your needs. For instance, you might want to:
- Reuse your firm's boilerplate language in multiple documents
- Reference a set of related documents in one main template and enable user s to choose the document that is pertinent to them
You cannot place INSERT instructions in a table.
Converting a Part of an Existing Template into a Second "Inserted" Template
In addition to using existing templates, you can select text in your current template and convert that text into a new template. At the same time, you use the INSERT instruction to add that content back into the parent template's document assembly process. You can also use the INSERT instruction to add that content into other templates document processes, as needed. For example, perhaps you realize that a section of your template could be reused in other templates. You can select this section of text, create an template from it, and then reference your new template in other related templates, using the INSERT instruction.
When you create templates by selecting existing template text, the new inserted (child) template uses the same component file as the parent template, as long as you save the child template to the same folder as the parent template.
If you save the child template to a different folder, a new, empty component file is created for the child template. If the child template uses variables from the parent template, you need to copy those variables into the new component file.
INSERT instructions inside a SPAN field will only work if the parent template and the inserted template use the same shared component file.
Use Insert to Select from Multiple Templates
You can let your users decide which child templates they want to reference if you surround your INSERT instruction with IF instructions. (See Include or Exclude a Single Version of Text Using a Simple IF Instruction or Expression and Include or Exclude Multiple Versions of Text Using IF and ELSE IF Instructions or Expressions.) If you have multiple instructions, you can place the True/False variables in a custom dialog and specify whether the dialog should use a multiple-select or single-select grouping.
If you want to enable your users to select several documents for assembly at the same time, be sure there’s a section break or page break at the bottom of each template so each assembled document starts on a new page.
Before working with section breaks in templates, you should become very familiar with the HotDocs Header and Footer Override Scenarios.
Specify File Names For Insertion During Assembly
When inserting template contents (likewise, when inserting images) in another template, you may not always know, during template development, which files you need to reference with an INSERT instruction. When this situation arises, you can instead use a variable INSERT in the template. A variable INSERT instruction enables you to specify the template’s file name during document assembly, rather than during template development. The type of variable you insert must accept text as an answer, which means you must use a Text variable , a Multiple Choice variable , or a Computation variable that produces a text result.
For example, say there are hundreds of sub-templates to choose from. It wouldn’t make sense to try to automate the template to account for each of these sub-templates—especially when template developers are creating new sub-templates on a regular basis. Using a variable INSERT instruction, however, you can script your template to specify the name of the inserted file at document assembly.
If you reference any specific templates in a variable INSERT instruction, make sure you include the template in the library when you run Template Manager. If you do not, Template Manager may not accurately report component usage information.
When publishing templates, you must manually add any files you reference in variable INSERT instructions to the published file by clicking the Additional Templates button on the Component File Properties General tab.