1 2 3 4 5 6 7 8 9 10 11 12 13 | from django.template import Library
register = Library()
@register.filter
def paragraphs(var, arg):
paras = var.replace("\r\n", "\n").split("\n\n")
return "\n\n".join(paras[:int(arg)])
@register.filter
def lines(var, arg):
lines = var.replace("\r\n", "\n").split("\n")
return "\n".join(lines[:int(arg)])
|
More like this
- Custom Admin Redirects by leitjohn 2 years, 10 months ago
- JSONField by deadwisdom 4 years, 5 months ago
- Generic object_detail view with multiple named URL filters by cotton 1 month, 3 weeks ago
- Format transition middleware by limodou 4 years, 11 months ago
- ByteSplitterField by Lacour 5 months, 2 weeks ago
Comments