2013-05-04 29 views
0

我想让我的GAE应用程序webapp2兼容。 此代码与Web应用工作很大:webapp2更改纯文本中的html标记

insert = '<p><font color="red"><b>some text</b></font></p>' 

template_values = { 
'insert': insert, 
... 
} 

path = ... 
self.response.out.write(template.render(path,template_values)) 

变量插入的内容是刚投入web页面输出的web应用。现在,变量的内容由webapp2“分析”,并且内容在插入网页时发生变化。

webapp2的插入这样的:

&lt;p&gt;&lt;font color=&quot;red&quot;&gt;&lt;b&gt;some text&lt;/b&gt;&lt;/font&gt;&lt;/p&gt; 

我怎么能回到原来的行为?

感谢您的任何帮助。

+2

IIRC,那是因为Django的自动转义内容。您可以通过添加“安全”过滤器来避免转义。像:'{{HTMLContent |安全}}' – SuperSaiyan 2013-05-04 12:37:11

+0

是答案吗? – 2013-05-04 12:45:59

+0

非常感谢!这是答案。 – Neverland 2013-05-04 16:56:03

回答