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
- Serving null files by ludvig.ericson 6 years, 3 months ago
- check if form has changed (deprecated) by guettli 5 years, 3 months ago
- Debug-only static serving by ludvig.ericson 5 years, 5 months ago
- Improved Accept header middleware by ludvig.ericson 4 years, 9 months ago
- Remove old fields on dumpdata generated json by facundo_olano 1 year, 8 months ago
Comments