Reputation: 6868
This is my code:
file = 'http://www.example.com/cdn/.eJwdyjsKksjdbf-sjhdfb-kajsfbnksj'
link = '%s/cdn/%s' % (self.base_url, file)
app.log.debug('link is: %s' % link)
return template.render(link_text=link_text, link=link)
Here the output of the log is as below:
2016-06-22 05:37:23,268 - app:log - DEBUG - 330 - 106622 - Thread-6 - link is: http://www.example.com/cdn/.eJwdyjsKksjdbf-sjhdfb-kajsfbnkshdbhj
But the output of template.render
for the link part is:
<div height=\\"40px\\" style=\\"width: 189px; height: 43px; line-height: 40px; background-color: #5c9eef; border-radius: 4px; text-align: center;\\">\\n
<a href=\\"http://www.example.com/cdn/\\" style=\\"text-decoration: none; font-weight: 300; line-height: 42px; font-family: tahoma; font-size: 15px;
letter-spacing: 1px; color: #fff;\\">Download File</a>\\n
The generated link is missing the part with .
! Does that mean jinja2
behaves odd on this character?! Is there anything I could do to solve this problem?
Upvotes: 0
Views: 882
Reputation: 9978
You need to mark your html as safe, otherwise Jinja performs autoescaping. This is as simple as:
from jinja import Markup
...
return template.render(link_text=link_text, link=Markup(link))
The other way you can do this is from the html template itself - just mark the variable as safe:
{{ my_variable | safe }}
Upvotes: 1