]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Custom Filters example inserts escaped <br>s 343/head
authorJörn Hees <dev@joernhees.de>
Sun, 15 Jun 2014 16:31:16 +0000 (18:31 +0200)
committerJörn Hees <dev@joernhees.de>
Sun, 15 Jun 2014 16:31:16 +0000 (18:31 +0200)
The example nl2br custom filter inserts escaped `&lt;br&gt;` <br> tags as a `Markup.replace` method seems to be aware of modifications and pass `str`/`unicode` arguments through `escape`.

docs/api.rst

index a4fe1bf4e065792ea10aa2ec43c1957f24afded8..02a8138c9a1d6a333134c750ffcd3904674f3ea8 100644 (file)
@@ -607,7 +607,7 @@ enabled::
 
     @evalcontextfilter
     def nl2br(eval_ctx, value):
-        result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
+        result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', Markup('<br>\n'))
                               for p in _paragraph_re.split(escape(value)))
         if eval_ctx.autoescape:
             result = Markup(result)