2

I want to pass HTML directly as a parameter in template(). I know I could do something like:

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

but I need to pass it directly when I call template, I tried replacing &lt and &gt with < > with javascript but that did not work. I want to do this:

{{results_of_i_in_array}}

and the loop will occur in my main rather than in the template, I never found anyone asking the same question. Note: this question is NOT a duplicate of this question.

I am using bottle default templating system, thanks in advance.

Community
  • 1
  • 1
Mohamed Emad
  • 123
  • 1
  • 14
  • check bottle documentation - maybe it has soemthing similar to `autoescape off` or `text|safe` – furas Feb 03 '17 at 10:26

1 Answers1

6

Bottle doc:

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>!'
shayelk
  • 1,606
  • 1
  • 14
  • 32
furas
  • 134,197
  • 12
  • 106
  • 148