Text Highlighting Filter

1
2
3
@register.filter
def highlight(text, word):
    return mark_safe(text.replace(word, "<span class='highlight'>%s</span>" % word))

More like this

  1. Readonly fields on Form/Modelform by Killarny 4 years, 3 months ago
  2. Tags & filters for rendering search results by exogen 5 years, 2 months ago
  3. Code syntax highlighting templatetag by badrunner 5 years, 9 months ago
  4. DRY menu Custom Template Tag by sergzach 1 year, 2 months ago
  5. Git Revision Template Tag by sbaechler 7 months, 1 week ago

Comments

(Forgotten your password?)