linebreaksli template filter

1
2
3
4
5
6
7
8
import re, string

def linebreaksli(value):
    "Converts strings with newlines into <li></li>s"
    value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines
    lines = re.split('\n', value)
    lines = ['<li>%s</li>' % line for line in lines]
    return '\n'.join(lines) 

More like this

  1. make an unordered html list by techiegurl 5 years ago
  2. Convert newlines into <p> and </p> tags by jheasly 6 years, 1 month ago
  3. Auto HTML Linebreak filter by punteney 5 years, 1 month ago
  4. filter for extracting a number of paragraphs from any HTML code by rafadev 1 year, 11 months ago
  5. Template filter that divides a list into exact columns by davmuz 1 year, 4 months ago

Comments

(Forgotten your password?)