Skip to content

ubajze/template_render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Template render

Overview

Python program that can be used to render templates with variable values. Program will take template, extract variables and ask user to enter values for these variables. After all variables have values, program generate text file with those values.

Requirements

Template must be in text format and all variables should be in format {{ variable }}.

Usage

Program could be used for example to create similar Cisco router configurations, where only couple of variables differs. You just create temlate and run program for every new configuration.

Example

Store the following configuration in text file with the name template:

!
interface FastEthernet 0/0
 ip address {{ ip_address }} {{ network_mask }}
 no shutdown
! 

Run program with -t option:

python template_render.py -t template

Program will ask you to enter values for ip_address and network_mask variable, for example 192.168.1.1 and 255.255.255.0.

The program will generate the following text output:

!
interface FastEthernet 0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown
!

About

Template render

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages