自定义jinja2转义标签


参考问题
参考资料
最终代码:

 1def safe_clean(text):
 2    from flask import Markup
 3    from bleach import clean
 4    tags = ['b','i','font','br']
 5    attrs = {
 6        '*':['style'],
 7        'font':['color']
 8    }
 9    styles = ['color']
10    return Markup(clean(text,tags = tags,
11                        attributes = attrs,
12                        styles = styles))

自定义filter过滤器

作者: honmaple
链接: https://honmaple.me/articles/2016/02/自定义jinja2转义标签.html
版权: CC BY-NC-SA 4.0 知识共享署名-非商业性使用-相同方式共享4.0国际许可协议
wechat
alipay

加载评论