Changelog
This changelog is generated automatically from GitHub Releases.
v0.6.3
2026-11-07 · GitHub
Decorator order no longer matters for async views on Flask, plus a user guide
- On Flask with Python 3.12 or newer, an
async defview works with your own decorators stacked in any order around[@template](https://github.com/template), with or withoutfunctools.wraps. Previously a sync decorator placed outside[@template](https://github.com/template)made Flask fail with “The view function did not return a valid response … it was a coroutine”. The decorated view now returns an object that awaits like the coroutine (soawait,asyncio.run()andcreate_task()all accept it) and is also a WSGI callable, so Flask can run it to completion when a sync decorator hands it back unawaited. Quart, Python 3.10 and 3.11, sync views, and directasyncio.run()calls on decorated views behave exactly as before. - New user guide at https://mkennedy.codes/docs/chameleon-flask/user-guide/: getting started, a Chameleon template primer, the
[@template](https://github.com/template)rulebook, friendly 404s, async views on Flask and Quart with a verified decorator-order table, testing, a troubleshooting field guide, how it works, and an FAQ. Every behaviour described was run before it was written. - The docs build now fails if the agent files or the user guide pages are missing from the output.
- Tests drive each decorator arrangement through Flask’s test client.
No breaking changes.
v0.6.2
2026-11-07 · GitHub
Clearer errors and wraps-aware async detection
[@template](https://github.com/template)now looks throughfunctools.wrapschains when deciding whether a view is async, so anasync defwrapped by your own sync decorator is awaited correctly instead of failing with “Invalid return type coroutine”.- When the outer decorator hides the
async def(nofunctools.wraps), the stray coroutine is closed and a FlaskChameleonException tells you to put[@template](https://github.com/template)directly on theasync def. - A view model containing the key
encodingnow raises a clear FlaskChameleonException (Chameleon reserves it as a render argument) instead of a confusing ChameleonTypeError. - Tests covering all three edge cases.
- Docs: README and API reference rewritten in a narrative voice, site rebuilt with Great Docs 0.17.0, and the navbar version badge is now taken from
pyproject.tomlat build time instead of the latest GitHub release.
No breaking changes: each of the fixed code paths previously failed.
v0.6.1
2026-06-11 · GitHub
Tighten types and docs across the public API
- Complete annotations: NoReturn on not_found, fix template_data: dict -> Any, modern X | None unions, full param/return types everywhere
- Cast the response passthrough (pyrefly caught the flask.Response mismatch)
- Pin ty and pyrefly to the venv via pyproject [tool.*] config
- Examples sections and module docstrings; document decoration-time template resolution
- Export exceptions at the package root with test coverage
- README: badges, default naming, Quart note, direct rendering section
- Example app: not_found demo with catalog and 404 templates
v0.6.0
2025-11-21 · GitHub
Release v0.6.0
New Feature: Namespace Restriction Control
Added support for controlling Chameleon’s namespace restriction, enabling better compatibility with attribute-based JavaScript frameworks like Vue.js and Alpine.js.
What’s New
The global_init() function now accepts a restricted_namespace parameter (defaults to True for backward compatibility). When set to False, Chameleon only treats its own namespaces (TAL, METAL, i18n) specially, allowing all other attributes to pass through unchanged.
Usage
import chameleon_flask
# Turn off namespace restriction for Alpine.js/Vue.js compatibility
chameleon_flask.global_init(
template_folder='templates',
auto_reload=True,
restricted_namespace=False # <-- Enable attribute-based JS frameworks
)Why This Matters
With restricted_namespace=False: - Chameleon only processes its own namespaces (tal:, metal:, i18n:) - All other attributes like x-data, x-on:click, x-bind:class, [@click](https://github.com/click), :class are left untouched - Perfect for templates using Alpine.js, Vue.js, or other attribute-based frameworks - No need to escape or work around Chameleon’s namespace restrictions
Backward Compatibility
This change is fully backward compatible. The default value is True, maintaining the existing behavior unless explicitly changed.
v0.5.1
2025-01-12 · GitHub
Things are getting stable now.
This release fixes a bug where the status code is not passed as part of the response. For example, the sync version is status code 201 whereas the async one is status code 200 with this bug (now fixed):
[@blueprint](https://github.com/blueprint).post('/saves/new')
[@template](https://github.com/template)('saves/partials/card-processing.pt', status_code=201)
def save_new():
# ...
[@blueprint](https://github.com/blueprint).post('/saves/new')
[@template](https://github.com/template)('saves/partials/card-processing.pt', status_code=201)
async def save_new():
# ...v0.0.5
2024-11-14 · GitHub
Add support for non-200 status code in template decorator. For example 201 for a POST handling view.
v0.0.4
2024-11-13 · GitHub
BREAKING CHANGE: Rename mimetype parameter named on template() to content_type (as that is that it represents).
v0.0.3
2024-11-13 · GitHub
There was a problem with 0.0.2 using quart responses. Now working.
v0.0.2
2024-11-13 · GitHub
Allow quart and flask raw responses.
v0.0.1
2024-11-13 · GitHub
First release, published to PyPI on 2024-11-07.
chameleon-flask began as a copy of the sibling fastapi-chameleon project, reworked for Flask and Quart. The package was first named the other way round; it became chameleon-flask because that name on PyPI was already taken.
global_init(template_folder, auto_reload=False, cache_init=True)sets up one process-wide Chameleon template loader.[@template](https://github.com/template)decorates sync and async Flask/Quart views; the view returns adictfor the template model, or aflask.Responseto pass straight through (redirects and the like). Usable bare, deriving the template name from the view, or with an explicit template path.- not_found() renders a friendly 404 page (
errors/404.ptby default) from inside a view. - response() renders a template directly to a
flask.Response. - Example app and a test suite; packaging via
pyproject.toml.