Template Rendering
Template rendering is a software technology that takes a template built using a template language like Jinja and injects (or passes) data into it. The result is content such as a static web application, text document, or configuration file. It is an excellent way to substitute values in the template or configuration files, forming an integral part of the DataOps.live data product platform architecture, as follows:
-
YAML configuration files
-
The DataOps reporting functionality, including the following components:
Therefore, it is worth looking at the principles of Template Rendering to understand how DataOps.live leverages its power.
Jinja template rendering
DataOps.live uses Jinja Template Rendering to inject data into YAML configuration files and for reporting purposes.
How?
Templates are developed using the Jinja Templating Language. A Jinja template is a text file containing variables, expressions, and tags. When the template is rendered, these variables and expressions get replaced with values, while the tags control the template's logic.
For instance, the Jinja Template Designer Documentation uses the following example to show what a simple template looks like:
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Webpage</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }} {# a comment #}
</body>
</html>
Jinja basics
Now that we understand what Jinja looks like, let's dive deeply into some basics.
As highlighted in the Jinja documentation, Jinja is a templating language similar to Python. MATE primarily uses it to write functional SQL. Jinji is used in other functions, including documentation, macros, and packages.
While the best place to learn Jinja is its Jinja Template Designer documentation, it is important to review the basics that are most often used in MATE.