@evalcontextfilter
def do_replace(eval_ctx, s, old, new, count=None):
 if (count is None):
  count = (-1)
 if (not eval_ctx.autoescape):
  return text_type(s).replace(text_type(old), text_type(new), count)
 if (hasattr(old, '__html__') or (hasattr(new, '__html__') and (not hasattr(s, '__html__')))):
  s = escape(s)
 else:
  s = soft_unicode(s)
 return s.replace(soft_unicode(old), soft_unicode(new), count)

@ evalcontextfilter def do_replace ( eval_ctx , s , old , new , count = None ) : if ( count is None ) : count = ( - 1 ) if ( not eval_ctx . autoescape ) : return text_type ( s ) . replace ( text_type ( old ) , text_type ( new ) , count ) if ( hasattr ( old , '__html__' ) or ( hasattr ( new , '__html__' ) and ( not hasattr ( s , '__html__' ) ) ) ) : s = escape ( s ) else : s = soft_unicode ( s ) return s . replace ( soft_unicode ( old ) , soft_unicode ( new ) , count )
return a copy of the value with all occurrences of a substring replaced with a new one .