Golden Configuration (IOS) - Jinja2 Templates
  • 17 Apr 2024
  • Dark
    Light
  • PDF

Golden Configuration (IOS) - Jinja2 Templates

  • Dark
    Light
  • PDF

Article Summary

Jinja2 Template Image

Before we start building the lab exercise, we’re going to take a look at Jinja2 Templates. For those less familiar, Jinja2 is a templating language developed for Python that allows users to take structured data and format it for human readability. Here we’ll build a simple template that will show you how this is done. Part of today’s workflow will leverage a Jinja2 Template in order to format text for ServiceNow, so this small exercise will give you a better idea of how that workflow operates. 

Jinja 2 Template Video

Step 1

From IAP Cloud, log in to your IAP instance by clicking on the blue Launch icon.

Step 2

From the IAP Home page, Click Automation Studio

Step 3

Click the + at the top of the left navigation panel.

Step 4

The Create window opens. Click the dropdown and select Template then Jinja2 Template

Step 5

Enter Template – XX (XX represents your initials) for the name and and Workshop for the group. Click CREATE.

Step 6

Using the sample JSON Data provided below, update the data on the left side of the screen. 

{
  "firstName": "",
  "title": "",
  "companyName": "",
  "repeatableTask": "",
  "vendorNames": []
}


Step 7

Using the sample template text below, update the template on the right side of the screen.  


My name is {{ firstName }}, and I'm a(n) {{ title }}.
Here at {{ companyName }}, we would like to automate {{ repeatableTask }}.
{% if vendorNames | length == 1 %}
The most common networking vendor I work with is {{ vendorNames[0] | title }}.
{% elif vendorNames | length > 1 %}
The most common networking vendors I work with are:
{% for vendor in vendorNames %}
 - {{ vendor | title }}
{% endfor %}
{% endif %}


Step 8

Using the sample template text, update the template on the right side of the screen and see how the output changes below.




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.