How do I pass Django's urlize template filter its autoescape parameter?

我们两清 提交于 2019-12-12 01:33:25

问题


Django urlize docs say:

The urlize filter also takes an optional parameter autoescape. If autoescape is True, the link text and URLs will be escaped using Django's built-in escape filter. The default value for autoescape is True.

I'd like to use this parameter, but the documentation says nothing about how to actually pass a keyword argument to a template filter. Is it possible, and if so, how do I do that?


回答1:


Apparently urlize gets that keyword argument from current autoescape settings, so the way to go seems like

{% autoescape off %}{{ value|force_escape|urlize }}{% endautoescape %}

(if you still want to escape the value)



来源:https://stackoverflow.com/questions/6316156/how-do-i-pass-djangos-urlize-template-filter-its-autoescape-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!