Rather than using `|safe` in the template, you should wrap the return value in `jinja2.Markup()`. That class is already marked "safe", and allows us to keep track of safety closer to the code (`escape` or `clean`) that makes it safe.