Module

contrib.flask

Flask integration for Kida.

Providesinit_kidato register a Kida environment and render helper on a Flask application. Flask's own Jinja environment remains unchanged.

Usage::

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

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 rendering for a Flask app without replacing Jinja. Registers a…
def init_kida(app: Any, *, template_folder: str | None = None, **env_kwargs: Any) -> Environment

Initialize Kida rendering for a Flask app without replacing Jinja.

Registers a Kida environment and render helper on the app. Templates are loaded from the app's template folder; Flask's Jinja environment is not replaced.

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