old_contents: # coding: utf-8
  
  from django.template import Library
  from ..html import TermsHTMLReconstructor
  
  register = Library()
  
  
  @register.filter
  def replace_terms(html):
      parser = TermsHTMLReconstructor()
      parser.feed(html)
      return parser.out
  
new_contents: # coding: utf-8
  
  from django.template import Library
  from django.template.defaultfilters import stringfilter
  from ..html import TermsHTMLReconstructor
  
  register = Library()
  
  
  @register.filter
  @stringfilter
  def replace_terms(html):
      parser = TermsHTMLReconstructor()
      parser.feed(html)
      return parser.out
  
subject: Make sure the filter arg is a string.