global_init()
Initialize the Chameleon template engine for your app.
Usage
global_init(
template_folder,
auto_reload=False,
cache_init=True,
)Call this once at startup, pointing it at the folder that holds your *.pt templates. Template paths used elsewhere (in template(), response(), not_found(), and generic_error()) are resolved relative to this folder.
Parameters
template_folder: str-
Path to the folder containing your Chameleon templates.
auto_reload: bool = False-
Reload templates from disk when they change. Handy in development; leave
Falsein production. Defaults toFalse. cache_init: bool = True-
When
True(the default), a second call is a no-op once the engine is already initialized. PassFalseto force re-initialization (for example, to switch template folders in tests).
Raises
FastAPIChameleonException-
If
template_folderis empty or is not a directory.