it/itf/frontpage/templatetags/itftags.py

30 lines
635 B
Python
Raw Normal View History

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