- 18 Oct 2024
-
DarkLight
-
PDF
Golden Configuration (IOS) - Jinja2 Templates
- Updated on 18 Oct 2024
-
DarkLight
-
PDF
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.