Adds Jinja2 template rendering support to FastAPI applications for server-side HTML generation.
fastapi-jinja is a Python library that integrates the Jinja2 template engine with FastAPI, allowing developers to render HTML templates directly from FastAPI route handlers. It solves the problem of server-side HTML generation in FastAPI applications by providing a simple decorator-based approach to pass data from views to templates. This enables building full-stack web applications using FastAPI without needing a separate frontend framework for basic pages.
FastAPI developers who need server-side rendering for HTML pages, such as those building traditional web applications, admin panels, or documentation sites with dynamic content.
Developers choose fastapi-jinja because it offers a lightweight, non-intrusive way to add Jinja2 templating to FastAPI with minimal boilerplate. Its decorator-based design keeps view logic clean while supporting both sync and async handlers, making it more integrated than manual template rendering solutions.
Adds integration of the Jinja template language to FastAPI.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses the @fastapi_jinja.template() decorator to automatically render Jinja2 templates with data from view methods, reducing boilerplate code as shown in the usage example where a dict is returned.
Works seamlessly with both synchronous and asynchronous FastAPI handlers, mentioned in the key features, making it flexible for various endpoint types.
Supports template auto-reloading during development via the auto_reload parameter in global_init(), enabling faster iteration without server restarts.
Follows a minimalistic approach, providing just enough to make Jinja2 feel native to FastAPI without added complexity, per the philosophy section.
The library is not yet on PyPI and described as 'fairly unstable' in the README, leading to potential breaking changes and lack of official support for production use.
Requires installation directly from GitHub or forking the repo, complicating dependency management and updates compared to standard PyPI packages.
Only integrates with Jinja2 templating, so projects needing other template engines or advanced features beyond Jinja2 might find it restrictive.