本文介绍了Jinja 2安全关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在理解像{{ something.render() | safe }}这样的表达式的作用时,我遇到了一个小问题.

I have a little problem understanding what an expression like {{ something.render() | safe }} does .

据我所见,没有safe关键字,它会输出整个html文档,而不仅仅是真实内容.

From what I have seen, without the safe keyword it outputs the entire html document, not just the true content.

我想知道的是它的实际作用,作用方式.

What I would like to know, is what it actually does, how it functions .

推荐答案

safe过滤器将字符串明确标记为安全",即,如果启用了自动转义,则不应自动转义.

The safe filter explicitly marks a string as "safe", i.e., it should not be automatically-escaped if auto-escaping is enabled.

此过滤器上的文档位于此处.

The documentation on this filter is here.

请参见手动转义部分,以了解哪些字符可以转义.

See the section on manual escaping to see which characters qualify for escaping.

这篇关于Jinja 2安全关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 16:30