@register.filter def highlight(text, word): return mark_safe(text.replace(word, "%s" % word))