Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html tornado |渲染|字符串用法_Html_Templates_Tornado - Fatal编程技术网

Html tornado |渲染|字符串用法

Html tornado |渲染|字符串用法,html,templates,tornado,Html,Templates,Tornado,我需要帮助理解龙卷风中渲染字符串的行为。 我正在使用下面的代码 tornado.escape.to_basestring(self.render_string("message.html", input_to_template=message)) message.html <div class="message">{% module linkify(input_to_template["body"]) %}</div> 现在,如果消息[“html”]是 <div

我需要帮助理解龙卷风中渲染字符串的行为。 我正在使用下面的代码

tornado.escape.to_basestring(self.render_string("message.html", input_to_template=message))
message.html

<div class="message">{% module linkify(input_to_template["body"]) %}</div>
现在,如果
消息[“html”]

<div class="message">&lt;img src=&quot;/media//uploads/Capture_23.PNG&quot; /&gt;</div>\n
它没有提到任何关于转义/取消转义html标记的内容。 如何使用此函数,以便在
消息[“html”]

我得到的输出是

<div class="message"><img src="/media//uploads/Capture_23.PNG" /></div>\n
\n

tornado模板系统自动逃逸除模块输出或
原始指令之外的所有内容;模块应自行进行转义。在这种情况下,转义实际上是由
linkify
模块完成的

linkify
接受纯文本并将其转换为html,因此它必须假设任何尖括号都是逐字显示的,并将其转义。您不想实际通过


如果要包含不转义的
message[“html”]
,最简单的方法是使用
raw
指令:
{%raw message[“html”]%}
。请参阅位于

的模板文档。tornado模板系统自动转义除模块输出或
raw
指令外的所有内容;模块应自行进行转义。在这种情况下,转义实际上是由
linkify
模块完成的

linkify
接受纯文本并将其转换为html,因此它必须假设任何尖括号都是逐字显示的,并将其转义。您不想实际通过

如果要包含不转义的
message[“html”]
,最简单的方法是使用
raw
指令:
{%raw message[“html”]%}
。请参阅位于的模板文档

"""
Generate the given template with the given arguments.    
We return the generated byte string (in utf8). To generate and
write a template as a response, use render() above.
"""
<div class="message"><img src="/media//uploads/Capture_23.PNG" /></div>\n