如何传递Django的urlize模板过滤器的autoescape参数? [英] How do I pass Django's urlize template filter its autoescape parameter?
问题描述
Django urlize
docs 说:
Django urlize
docs say:
urlize
可选参数autoescape
。如果autoescape
是True
,链接文字和URL将使用Django的内置逃避
过滤器。 autoescape的默认值为True
。
The
urlize
filter also takes an optional parameterautoescape
. Ifautoescape
isTrue
, the link text and URLs will be escaped using Django's built-inescape
filter. The default value for autoescape isTrue
.
我想使用这个参数,但文档中没有说明如何实际地将一个关键字参数传递给模板过滤器。是否可能,如果是,我该如何做?
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?
推荐答案
显然 urlize
从当前autoescape设置中获取该关键字参数,所以去的方式看起来像
Apparently urlize
gets that keyword argument from current autoescape settings, so the way to go seems like
{% autoescape off %}{{ value|force_escape|urlize }}{% endautoescape %}
(如果还想逃避价值)
这篇关于如何传递Django的urlize模板过滤器的autoescape参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!