Variables in the template represent dynamic data and are used to insert and display values from a data source within the template. Variables are enclosed in double curly braces {{ }}. They can display values, perform operations, or apply filters to manipulate the data before rendering it in the template.

Various template elements, including namespaces, color codes, option definitions, generic macros, and a table of contents macro, can be modified.

Jinja template's static content is adjustable except for the setup code.

Below is an example of variables from a pre-built report export template.

Common Template Variables

Each template will have a different combination of variables and parameters found at the beginning of the template. A specific template may not include all of the variables listed below.

  • Namespaces: A dictionary or context containing variable names and their corresponding values. Jinja2 uses this namespace to replace the placeholder with the actual values when rendering a template. Several namespaces are defined to store variables of different data types, including strings, numbers, lists, booleans, integers, and floats.

  • Color Codes: Used to change table headings colors, criticality backgrounds within tables, and severity text colors.

  • Display Options: Used for tables and other display configurations in the exported report.

  • Cover Pages: Used to personalize the report by updating the cover page's colors, background images, and logo.

  • Option Definitions: Defines cover page options, display settings, and formatting options. For example, setting the cover page to "3," enabling strict narratives, and setting the display of informational findings to true.

  • Generic Macros: Provides flexibility in customizing the template's behavior, such as setting report field variables, displaying narratives with customizable headings and handling errors.

  • Table of Contents Macro: Generates and defines a table of contents.

  • Other Macros: Additional macros are used to set severity colors and control the spacing between findings in the report.

  • Static Content vs. Jinja Code: Anything that is not Jinja code can be modified without inducing errors on export. Any static content can be changed. Additional static content can be added anywhere other than the setup code section. It is easy to identify Jinja code statements, as they are always bookended with one of two methods:

    1. Logic Statements {% <Logic statements are bracketed with curly-brace percent signs> %}

    2. Print Statements {{ <Print statements are bracketed with double curly braces> }}

Last updated

© 2024 PlexTrac, Inc. All rights reserved.