jinja variable code example
Example 1: jinja inheritance
{% extends "base.html" %}
{% block title %}Index{% endblock %}
{% block head %}
{{ super() }}
<style type="text/css">
.important { color:
</style>
{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}
Example 2: jinja if
{% if 'priority' in data %}
<p>Priority: {{ data['priority'] }}</p>
{% endif %}
Example 3: jinja2 set variable
{% if 'clear' in forcast_list[4] %}
{% set img = "sunny.png" %}
{% elif "cloudy" in forcast_list[4] %}
{% set img = "sun-cloudy-thunder.png" %}
{% endif %}
Example 4: jinja if else
{% if "Already" in RepoOutput[RepoName.index(repo)] %}
{% set row_class = "good" %}
{% else %}
{% set row_class = "error" %}
{% endif %}
<td class="{{ row_class }}"> {{ RepoOutput[RepoName.index(repo)] }} </td>