Skip to content

Document filters that return RichText or InlineImage - #199

Merged
cvas22 merged 1 commit into
mainfrom
docs/134-filters-richtext-image
Nov 23, 2026
Merged

cvas22 merged 1 commit into
mainfrom
docs/134-filters-richtext-image

Conversation

@cvas22

@cvas22 cvas22 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What this changes

#134 asks for filters like {{ logo|image_from_base64(40) }} and {{r title|to_rich_text(bold=True) }} so the template decides the formatting and the service only sends plain data. That already works with a custom jinja_env, with or without autoescape. The docs only said "RichText objects are not compatible with Jinja2 filters", which reads like it doesn't. I added an example under Jinja custom filters and clarified that note, since it's only about filtering a RichText, not returning one.

Fixes #134

How I tested it

New unit test renders a filter that returns a RichText and one that returns an InlineImage, with autoescape on and off. All unit tests pass locally.

  • Tests added or updated in tests/unit
  • CHANGES.rst updated if users will notice the change (not needed, docs only)
  • Docs updated if behavior or the API changed

This already works, but the docs said RichText and filters don't mix.
Add an example and a test so it keeps working.

Fixes #134
@cvas22
cvas22 force-pushed the docs/134-filters-richtext-image branch from ff8b19e to 9b85624 Compare November 23, 2026 11:35
@cvas22
cvas22 merged commit 486e953 into main Nov 23, 2026
11 checks passed
@cvas22
cvas22 deleted the docs/134-filters-richtext-image branch November 23, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tests Changes to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for creating RichText or InlineImages using filters

1 participant