A Unix-style Python web framework: filesystem routing, flat files, messages and cron, with CGI's simplicity at modern speed.

0 downloads

dbbasic-web/dbbasic_web/templating.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-web.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-web.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-web.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst Replace multipart parser with stdlib-only implementation eb957a2 9 months, 2 weeks ago History
templating.py · 427 bytes · 14 lines
1"""Template rendering with Jinja2"""
2from jinja2 import Environment, FileSystemLoader, select_autoescape
3from .settings import TEMPLATES_DIR
4
5env = Environment(
6 loader=FileSystemLoader([str(TEMPLATES_DIR)]),
7 autoescape=select_autoescape(["html", "xml"]),
8)
9
10
11def render(template_name: str, **ctx) -> str:
12 """Render a template with context"""
13 tmpl = env.get_template(template_name)
14 return tmpl.render(**ctx)