@register.filter
def breadcrumbs(url):
home = ['
you are here : home »',]
links = url.strip('/').split('/')
bread = []
total = len(links)-1
for i, link in enumerate(links):
if not link == '':
bread.append(link)
this_url = "/".join(bread)
sub_link = re.sub('-', ' ', link)
if not i == total:
tlink = '%s »' % (this_url, sub_link, sub_link)
else:
tlink = '%s' % sub_link
home.append(tlink)
bcrumb = "".join(home)
return mark_safe(bcrumb)