如何将 html 直接传递给模板

How to pass html directly to template

我想在template()中直接将HTML作为参数传递。 我知道我可以做类似的事情:

%for i in array:
  <a>{{i}}</a>
%end

但是调用template的时候需要直接传过去, 我尝试用 < > 和 javascript 替换 &lt&gt,但这没有用。 我想这样做:

{{results_of_i_in_array}}

并且循环将出现在我的主程序中而不是模板中, 我从来没有发现有人问同样的问题。 注意:此问题不是 this question.

的重复问题

我正在使用 bottle 默认模板系统,在此先感谢。

瓶子文档:

You can start the expression with an exclamation mark to disable escaping for that expression:

>>> template('Hello {{name}}!', name='<b>World</b>')
u'Hello &lt;b&gt;World&lt;/b&gt;!'
>>> template('Hello {{!name}}!', name='<b>World</b>')
u'Hello <b>World</b>!'