From 93b6d72c72a6b08d37ed749eac489d78eeed859a Mon Sep 17 00:00:00 2001 From: Dave Gaeddert Date: Fri, 21 Jun 2024 21:50:23 -0500 Subject: [PATCH] More docs --- bolt/bolt/signals/README.md | 13 ++++++++++++- bolt/bolt/templates/README.md | 20 ++++++++++++++++++++ bolt/bolt/templates/jinja/README.md | 7 ++++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 bolt/bolt/templates/README.md diff --git a/bolt/bolt/signals/README.md b/bolt/bolt/signals/README.md index 5a7810ecd9..eaecfe8a8d 100644 --- a/bolt/bolt/signals/README.md +++ b/bolt/bolt/signals/README.md @@ -1,3 +1,14 @@ -# signals +# Signals Run code when certain events happen. + +```python +from bolt.signals import request_finished + + +def on_request_finished(sender, **kwargs): + print("Request finished!") + + +request_finished.connect(on_request_finished) +``` diff --git a/bolt/bolt/templates/README.md b/bolt/bolt/templates/README.md new file mode 100644 index 0000000000..b64e022454 --- /dev/null +++ b/bolt/bolt/templates/README.md @@ -0,0 +1,20 @@ +# Templates + +Render HTML templates using Jinja. + +Templates are typically rendered in `TemplateViews`, +but you can also render them directly to strings for emails or other use cases. + +```python +from bolt.templates import Template + + +Template("comment.md").render({ + "message": "Hello, world!", +}) +``` + +Template files can be located in either a root `app/templates`, +or the `templates` directory in any installed packages. + +[Customizing Jinja](./jinja/README.md) diff --git a/bolt/bolt/templates/jinja/README.md b/bolt/bolt/templates/jinja/README.md index ff89654a28..10dd592636 100644 --- a/bolt/bolt/templates/jinja/README.md +++ b/bolt/bolt/templates/jinja/README.md @@ -1,6 +1,4 @@ -# Templates - -Render templates using Jinja2. +# Jinja Templates can be stored inside `INSTALLED_PACKAGES` (ex. `app//templates`) or in the `templates` directory at the root of your project (ex. `app/templates`). @@ -11,6 +9,9 @@ which the whole app depends on. ### Package templates +Since all template directories are effectively "merged" together, +packages will typically namespace their own templates such as `app/users/templates/users/delete.html`. + ## Jinja There is a default set of globals, filters, and extensions.