You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for creating RichText or InlineImages using filters #581
Is your feature request related to a problem? Please describe.
I am developing a universal microservice for generating reports, and it would be convenient to be able to specify in advance all available filters that convert text to rich text, adjust colors, etc., convert a link or file path to InlineImage, etc.
It is very painful for me to hardcode the available operations for each type of report. And instead of editing in two places (the template and the service that sends the generation request with the context), it would be great to describe all this once in the reporting service, and then solve everything using the template.
Describe the solution you'd like
I think the syntax could be something like
{{ image_id|image_from_id(400, 400) }} # download image by id and set imgsize 400x400
{{ image_content|image_from_base64(400,400) }} # convert bs64 string to image and set imgsize 400x400
{{ news_header|to_rich_text(arg1,arg2,arg3) }}
Describe alternatives you've considered
If my task can be solved using the existing code base, please tell me how it can be implemented? I would like to avoid hardcoding inside the python service (except hardcode universal functions, the use of which can be defined in the template)
@hurek fyi, filters that return a RichText or InlineImage work with a custom jinja_env, e.g. jinja_env.filters['image_from_base64'] = lambda v, mm: InlineImage(tpl, io.BytesIO(base64.b64decode(v)), width=Mm(mm)). I'm documenting it in Docform (the maintained fork at https://github.com/cvas22/docform, docform on PyPI) in cvas22/docform#199, so you can switch over if you like.
Activity
cvas22 commentedon Nov 23, 2026
@hurek fyi, filters that return a
RichTextorInlineImagework with a customjinja_env, e.g.jinja_env.filters['image_from_base64'] = lambda v, mm: InlineImage(tpl, io.BytesIO(base64.b64decode(v)), width=Mm(mm)). I'm documenting it in Docform (the maintained fork at https://github.com/cvas22/docform,docformon PyPI) in cvas22/docform#199, so you can switch over if you like.cvas22 commentedon Nov 23, 2026
@hurek the docs example is merged in Docform now (cvas22/docform#199).