Ejemplo n.º 1
0
def title(value):
    """
    A slightly better title template filter.

    Same as Django's builtin ``title`` filter, but operates on individual words
    and leaves words unchanged if they already have a capital letter.
    """
    title_word = lambda w: w if RE_UPPERCASE.search(w) else old_title(w)
    return re.sub('(\S+)', lambda m: title_word(m.group(0)), value)
Ejemplo n.º 2
0
def title(value):
    """
    A slightly better title template filter.

    Same as Django's builtin ``title`` filter, but operates on individual words
    and leaves words unchanged if they already have a capital letter.
    """
    title_word = lambda w: w if RE_UPPERCASE.search(w) else old_title(w)
    return re.sub('(\S+)', lambda m: title_word(m.group(0)), value)
Ejemplo n.º 3
0
def title(value):
    '''
    A slightly better title template filter.

    Same as Django's builtin `~django.template.defaultfilters.title` filter,
    but operates on individual words and leaves words unchanged if they already
    have a capital letter or a digit. Actually Django's filter also skips
    words with digits but only for latin letters (or at least not for
    cyrillic ones).
    '''
    return ' '.join([
        any([c.isupper() or c.isdigit() for c in w]) and w or old_title(w)
        for w in value.split()
    ])
Ejemplo n.º 4
0
 def title_word(w):
     return w if RE_UPPERCASE.search(w) else old_title(w)
Ejemplo n.º 5
0
 def title_word(w):
     return w if RE_UPPERCASE.search(w) else old_title(w)