File size: 413 Bytes
350392a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
Page rendering using a lightweight template.
"""

from pathlib import Path
from string import Template
from typing import Dict


_TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "page.html.tmpl"


def render_page(context: Dict[str, str]) -> str:
    template_text = _TEMPLATE_PATH.read_text(encoding="utf-8")
    template = Template(template_text)
    return template.safe_substitute(context)