Jinja2 Filter To Convert Custom Markup To Html
Having the autoescape property on (I want to keep it that way), I want user to be able to enter some custom markup, to have the opportunity to format text. For example, [s][/s] wil
Solution 1:
Problem found. It's double escaping the string - rather silly. This code works flawlessly:
@app.template_filter()@evalcontextfilterdefmark2html(eval_ctx, value):
result = value.replace('[s]',u'<strong>')
result = result.replace('[/s]',u'</strong>')
if eval_ctx.autoescape:
result = Markup(result)
return result
Note, value shouldn't be escaped, as autoescape property is on.
Post a Comment for "Jinja2 Filter To Convert Custom Markup To Html"