Repository navigation
Document filters that return RichText or InlineImage - #199
Merged
Merged
Conversation
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
force-pushed
the
docs/134-filters-richtext-image
branch
from
November 23, 2026 11:35
ff8b19e to
9b85624
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 customjinja_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
RichTextand one that returns anInlineImage, with autoescape on and off. All unit tests pass locally.tests/unitCHANGES.rstupdated if users will notice the change (not needed, docs only)