From http://twig.sensiolabs.org/doc/filters/replace.html
{{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }} {# outputs: I like foo and bar if the foo parameter equals to the foo string. #} {# http://stackoverflow.com/questions/4943880/str-replace-in-twig #}