mark last breadcrumb active
This commit is contained in:
parent
52b535c608
commit
77de488521
@ -7,9 +7,9 @@ class BreadcrumbItem(object):
|
|||||||
self.title = title
|
self.title = title
|
||||||
self.href = href
|
self.href = href
|
||||||
|
|
||||||
def render(self, documentRoot):
|
def render(self, documentRoot, active=False):
|
||||||
return '<li class="breadcrumb-item"><a href="{documentRoot}{href}">{title}</a></li>'.format(
|
return '<li class="breadcrumb-item {active}"><a href="{documentRoot}{href}">{title}</a></li>'.format(
|
||||||
documentRoot=documentRoot, href=self.href, title=self.title
|
documentRoot=documentRoot, href=self.href, title=self.title, active="active" if active else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -21,9 +21,11 @@ class Breadcrumb(object):
|
|||||||
return """
|
return """
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
{crumbs}
|
{crumbs}
|
||||||
|
{last_crumb}
|
||||||
</ol>
|
</ol>
|
||||||
""".format(
|
""".format(
|
||||||
crumbs="".join(item.render(documentRoot) for item in self.items)
|
crumbs="".join(item.render(documentRoot) for item in self.items[:-1]),
|
||||||
|
last_crumb="".join(item.render(documentRoot, True) for item in self.items[-1:]),
|
||||||
)
|
)
|
||||||
|
|
||||||
def append(self, crumb: BreadcrumbItem):
|
def append(self, crumb: BreadcrumbItem):
|
||||||
|
Loading…
Reference in New Issue
Block a user