Module

contrib.flask

Flask integration for Kida.

Providesinit_kidato replace Flask's default Jinja2 engine with Kida.

Usage::

from flask import Flask
from kida.contrib.flask import init_kida

app = Flask(__name__)
kida_env = init_kida(app)

@app.route("/")
def index():
    return render_template("index.html", title="Home")

Functions

init_kida 3 Environment
Initialize Kida as the template engine for a Flask app. Replaces Flask's defau…
def init_kida(app: Any, *, template_folder: str | None = None, **env_kwargs: Any) -> Environment

Initialize Kida as the template engine for a Flask app.

Replaces Flask's default Jinja2 environment with Kida. Templates are loaded from the app's template folder.

Parameters
Name Type Description
app Any

Flask application instance.

template_folder str | None

Override for template directory. Defaults toapp.template_folder. **env_kwargs: Additional kwargs passed to Kida Environment.

Default:None
**env_kwargs Any
Returns
Environment
render_template 2 str
Render a template using the current app's Kida environment. Call this from a F…
def render_template(template_name: str, **context: Any) -> str

Render a template using the current app's Kida environment.

Call this from a Flask request context. Requiresinit_kida() to have been called on the app.

Parameters
Name Type Description
template_name str

Name of the template to render. **context: Template context variables.

**context Any
Returns
str