Template Builder UI
  • 02 Apr 2024
  • Dark
    Light
  • PDF

Template Builder UI

  • Dark
    Light
  • PDF

Article Summary

This section provides a brief walk-through of the Template Builder interface. The Data Console and Template areas are parsed in real-time against your templates to give instant feedback about what is working and what is not.

A description of each numbered element is provided in the reference table that follows.

Figure 4: Template Builder UI

04_template_interface

Label UI Element Function
1 Toolbar Icons for completing quick actions from anywhere within Automation Studio. These icons (from left to right) are: Create, Dashboard, Search, Import, and View Documentation.
2 Data The Data area serves as a way to test your template against a typical text response you would expect. This text will be parsed by your template and the output will be displayed in the Response area below. Any text can be parsed by TextFSM. If Jinja2 is selected, then JSON is required. The most common use case is to parse CLI response text since it usually does not provide a system level response that can be parsed.
3 Template The Template area contains the TextFSM (or Jinja2) template that will parse your console text. Use the prebuilt templates to modify the TextFSM template; you can also use it as a guide to write your own custom template. As you make modifications to the template, the Response area will update with the data object from TextFSM (or Jinja2).
4 Save & More Options Click the first icon to Save. Click the stacked dots button (second icon) to display additional menu options to view metatdata and clone, delete, or export the template.
5 Templates Collection Click the arrow to expand and view all available templates. Each template is divided into a custom group, usually based on the device type. You can click on any template to view it in the main canvas (right of left side navbar). Users can search for template items within a collection.
6 Output Response Output from TextFSM or Jinja2 parsing is displayed in the Output area in the form of a data table. This response can be used in workflows in the form of an object.

TextFSM

TextFSM can be difficult to understand at first but if you use existing templates as your guide, you can become more familiar with how they work. With the real-time TextFSM engine, you can see how your response is updated when the Template or Console text is modified. You can copy/paste example templates into Template Builder and modify the value/state definitions to create a custom file.

Note: For more information on TextFSM, refer to following wiki on GitHub: Google TextFSM Wiki.

Jinja2

Jinja2 is a widely known templating engine for Python, and Template Builder is designed to render Jinja2 templates for parsing command outputs into JSON objects to be utilized in workflows. Of note, values passed to a Jinja2 template are within the data object. Moreover, there is a workflow task to render Jinja2 templates from within workflows.

The renderJinjaTemplate task generates output from a template file in the templates folder of app-template_builder.

Note: For more information on Jinja2, refer to this link.

Referenced below are two simple examples of Jinja2 templates. The first example template uses variables, and the second one uses an iteration.

Figure 5: Jinja2 Variables Template

05_jinja2_variables_example

Figure 6: Jinja2 Iteration Template

06_jinja2_iteration_example


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.