from django import template register = template.Library() ''' Used to format titles in the front slider boxes >>>format_title("Script Bank") >>>SCRIPT BANK >>>format_title("Script-Bank") >>>SCRIPT-BANK ''' def format_title(value): v = value.strip() if v.find('-') != -1: splitter = "-" else: splitter = " " words = v.split(splitter) l = len(words) if l > 1: boldWord = "" + words[l - 1] + "" return (splitter.join(words[:l-1]) + splitter + boldWord).upper() else: return words[0].upper() register.filter("format_title", format_title)