from jinja2 import Template

# Built in jinja template

bgptext = """
router bgp {{ local_as }}
  neighbor {{ peer1_ip }} remote-as {{ peer1_as }}
    update-source loopback99
    ebgp-multihop 2
    address-family ipv4 unicast
  neighbor {{ peer2_ip }} remote-as {{ peer2_as }}
    address-family ipv4 unicast
"""

# Variables to pass in

my_vars = {"local_as": 10, "peer1_ip": "10.1.20.2", "peer1_as": 20, "peer2_ip": "10.1.30.2", "peer2_as": 30} 

# Convert to jinja template and render it based on my_vars

j2_template = Template(bgptext)
output = j2_template.render(**my_vars)
print(output)
