Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
In [2]:
!pip3 install jinja2
In [5]:
from jinja2 import Template
from argparse import Namespace
In [6]:
template = Template("Hello {{ name }}!")
template.render(name="John Doe")
Out[6]:
In [9]:
s = """<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
"""
s = Template(s).render(users=[Namespace(username="Ben", url="www.legendu.net")])
print(s)
In [ ]: