Python module - Jinja
- Details
- Last Updated: Friday, 22 October 2021 00:09
- Published: Friday, 22 October 2021 00:08
- Hits: 494
Jinja:
Jinja is template making module in Python. It's a template engine or template processor. that takes a template and processes it to produce documents. We can specify various fields of template using variables, then substitute these var with different set of values when passed thru Jinja, resulting in document for 100's of different data. So, Jinja is basically a template to document converter tool.
A very good link for tutorial is here: https://zetcode.com/python/jinja/
Installation:
Just like other python modules, Jinja is not installed by default, and we have to install the Jinja module
We use the pip3
tool to install Jinja. Type below cmd on Terminal prompt.
$ sudo pip3 install jinja2
Basics:
I had seen Jinja being used in a lot of Verilog testcases, where you want to update a section of testcases based on some other text file, say signals.txt. You use Jinja to generate the testcase document based on a template that you write manually. We use signals.txt file as our data, and based on this data, the document is created from the template.