我想在turbogears中止函数中使用一些HTML消息。Turbogears中止函数自动转义HTML代码
虽然名称不完全匹配(我用的是“tg.abort”功能),这是中止的定义,我发现: abort
目前使用的代码:
from tg import abort
message="The following {} occured, this is due to {}, please visit this url : {}".format(error, reason, url)
abort(status_code=502, detail=message)
我想要有这样的事情:
from tg import abort
message="""The following error occured : {}</br>
The most probable reason would be {} </br>
<a href="{}">Your solution might be found here</a>
""".format(error, reason, url)
abort(status_code=502, detail=message)
我认为内容会自动转义。
HTML页面从abort函数生成的,endering是这样的:
<html>
<head>
<title>502 Bad Gateway</title>
</head>
<body>
<h1>502 Bad Gateway</h1>
Bad gateway.<br /><br />
The following error occured : hungry<br/>
The most probable reason would be : maybe you should eat </br>
<a href="http://dummyurl">Your solution might be found here</a>
</body>
</html>
如果你有如何插入HTML代码没有逃脱任何想法,我会非常有兴趣。 另外我真的很关注abort方法,我知道我可以使用一些专门的页面来使用模板框架(如网站的其他部分)。
非常感谢。
问候