Skip to content

Add support for creating RichText or InlineImages using filters #581

Open

Description

@hurek

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)

Activity

  1. cvas22 commented on Nov 23, 2026

    @cvas22

    @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.

  2. cvas22 commented on Nov 23, 2026

    @cvas22

    @hurek the docs example is merged in Docform now (cvas22/docform#199).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions