Skip to main content

bobtail-jinja2

Bobtail middleware for Jinja2 templating

Install

pip install bobtail-jinja2

Usage

from bobtail_jinja2 import BobtailJinja2, Response

app = Bobtail(routes=routes)

app.use(BobtailJinja2(template_dir="templates"))

Render the template in a Bobtail handler. BobtailJinja2 provides a Bobtail handler Response type that also include the Jinja2 template attribute for IntelliSense etc.

from bobtail import AbstractRoute, Request
from bobtail_jinja2 import BobtailJinja2, Response
class HomeRoute(AbstractRoute):

    def get(self, req: Request, res: Response) -> None:
        res.set_headers({
            "Content-Type": "text/plain",
        })
        res.jinja2.render(res, "routes/home.jinja2", data={"title": "Welcome to Lanka Note"})

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bobtail_jinja2-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file bobtail_jinja2-0.0.2.tar.gz.

File metadata

  • Download URL: bobtail_jinja2-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for bobtail_jinja2-0.0.2.tar.gz
Algorithm Hash digest
SHA256 fa1726016be5051e779c74a5e24f562be4504679583f4b526e31de3b87750516
MD5 482602cf2783d9eb3c0b36fb7e11f8e7
BLAKE2b-256 e9ef566b6a73720b0f0ebdc709aa0ea88696766600e1c1c5dc1ec441741fc141

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 file

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page