File: hello.py

package info (click to toggle)
python-minijinja 2.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 232 kB
  • sloc: python: 525; makefile: 40; sh: 30
file content (29 lines) | stat: -rw-r--r-- 571 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from minijinja import Environment

INDEX = """{% extends "layout.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block body %}
  <ul>
  {%- for item in items %}
    <li>{{ item }}
  {%- endfor %}
  </ul>
{% endblock %}
"""
LAYOUT = """<!doctype html>
<title>{% block title %}{% endblock %}</title>
<body>
  {% block body %}{% endblock %}
</body>
"""

env = Environment(templates={
    "index.html": INDEX,
    "layout.html": LAYOUT,
})

print(env.render_template(
    'index.html',
    page={"title": "The Page Title"},
    items=["Peter", "Paul", "Mary"]
))