File: hello.py

package info (click to toggle)
python-minijinja 2.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 468 kB
  • sloc: python: 723; makefile: 40; sh: 31
file content (29 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (2)
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"]
))