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. Humanize lists of strings in templates by ChipX86 4 years, 8 months ago
  2. Readonly fields on Form/Modelform by Killarny 2 years, 11 months ago
  3. Page numbers with ... like in Digg by Ciantic 2 years, 10 months ago
  4. Tags & filters for rendering search results by exogen 3 years, 10 months ago
  5. NewForms Readonly / Edit Pattern by FreddieP 4 years, 2 months ago

Comments

(Forgotten your password?)