Replace multiple values with jinja2

Your expression seems to work just fine. If I create a template with
the jinja2 expression from your question:

>>> import jinja2
>>> t = jinja2.Template('{{ test1 | replace("value1","my_value1") | replace("value2","my_value2") }}')

And then render it, passing in a value for test1 that contains both
of the target replacement strings:

>>> output = t.render(test1="this has both value1 and value2")

I get a string that has both values replaced:

>>> print (output)
this has both my_value1 and my_value2
>>> 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)