# Guidelines for Configuration Template

*#Substitution*, Conditioning, and Looping in the Template should be in the Jinja2 standard. For more tutorials, refer to <http://jinja.pocoo.org/docs/2.10/>.

## **Points to Remember**

Always enclose the commands within **{% %}** for "if," and "for," and "while" conditional statements

Always enclose the variables inside **{{ }}** for substitution

## **Sample Template Configuration**

**Example 1:** Create an Empty List, add values to the List, and DO a simple ‘For Loop’

\# Declaring a string variable to store value from *Runtime* or user. The default (“”) function will make the variable empty string till the USER input

```
{% set myinput = Runtime.interface_list | default(“”) %}
```

\# Converting User Input to a list using the Split function

```
{% set mylist = myinput .split(",") %}
```

*#Doing* for Loop or Looping of Each Item

```
{% for each_interface in mylist %}
      <command prompt="#">int {{each_interface}}</command>
      <command prompt="#">shutdown</command>
```

\# for requires *endfor* to close the section

```
{% endfor %}
```

**Example 2:** Conditions (if case elif Case and else case)

```
{% for each_interface in mylist %}
        {% if each_interface == "Gi0/1" %}
                  <command prompt="#">int {{each_interface}}</command>
                  <command prompt="#">shutdown</command>
        {% elif each_interface == "Gi0/2" %}
                   <command prompt="#">int {{each_interface}}</command>
                   <command prompt="#">no shutdown</command>
        {% else %}
                    <command prompt="#">I dont know</command>
        {% endif %}
{% endfor %}
```

**Example 3:** Taking List Input from a Trigger

**#down\_interface\_list\_cisco\_ios** is a Trigger in Configuration Trigger

```
{% set mylist1 = Trigger.down_interface_list_cisco_ios | default([]) %}
{% for each_interface in mylist1 %}
      <command prompt="#">int {{each_interface}}</command>
      <command prompt="#">shutdown</command>
{% endfor %}
```

**Example 4:** Disable the Interface named ‘Ether’

***# String Manipulation startswith, endswith, find, lower, upper, strip***

```
{% set myinput = Runtime.InterfaceNames | default ("") %}
{% set mylist = myinput.split(",") %}
{% for each_item in mylist %}
      {% if each_item.lower().startswith("ether") %}        
            <command prompt="#">int {{each_item}}</command>
            <command prompt="#">shutdown</command>
   {% endif %}
{% endfor %}
```

**Example 5:** Taking the First Element from the Trigger

```
{% set mylist = Trigger.down_interface_list_cisco_ios |default ([]) %}\

{% if mylist %}
    <command timeout ="10" prompt ="#" >config t</command>        
    <command timeout ="10" prompt ="#" >interface {{mylist[0]}} </command>
    <command timeout="10" prompt  ="#" >IP address 172.17.230.2    
255.255.255.252</command>
     <command timeout ="10" prompt  ="#" >no shut</command>
{% endif %}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infraon.io/infraon-help/infinity-user-guide/infraon-configuration/it-operations/network-configuration/configuration-template/guidelines-for-configuration-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
