Overview: Insert the Contents of One Template into Another's Assembly Process

You can use the INSERT instructionAn instruction that inserts one template into another. For example, if boilerplate text needs to be used in multiple documents, a template An instruction that inserts the contents of one template into another. For example, if you have boilerplate text you need to use in multiple documents, you can create a template that contains that text and use the Insert intruction in each template that requires the boilerplate text to insert that content. This way, if you need to make a change to the text, you only need to update one template. to tell HotDocs to insert an existing template's contents into the document assemblyThe process HotDocs goes through as it processes scripts in the template and merges answers into the document produced from the template. At the end of the assembly process, the user has a document tailored to his or her needs. 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 userThe customer, client, or person who assembles documents from templates. (See also template developer.)s to choose the documentThe file that is created after a template has been assembled. 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 variableA component that is used to represent changeable text (such as names, dates, numbers, etc.) in the template. Types of variables include Text, Date, Number, True/False, Multiple Choice, Computation, and Personal Information. 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 variableA type of component that merges text in the document., a Multiple Choice variableA type of component that merges a predefined answer in the document., or a Computation variableA type of component that performs calculations or executes other instructions within the template. Computation variable scripts are created using the HotDocs scripting language. 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 scriptOne or more instructions and/or expressions that generate a value or execute some kind of procedure. 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 libraryA window used to display and organize templates. The library does not store the actual files—instead, it contains shortcuts (or links) to the files, which are stored on disk. In addition to the template library, HotDocs also uses an answer library, which is more commonly known as Answer File Manager. 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.