def render(self): if not self.is_visible(): return '' if self.is_alt_icon_visible(): icon_class = self.alt_icon_class else: icon_class = self.icon_class if icon_class: icon = html.SPAN(_class="icon") else: icon = '' item_class = ' '.join( tuple(self.default_classes) + (icon_class,)).strip() return html.link_other( ' '.join([icon + html.SPAN(self.label, _class="label")]), self.get_path(), bottle.request.original_path, lambda s, _class: html.SPAN(s, _class='active ' + item_class), _class=item_class)
def test_link_other_common_kwargs(): s = mod.link_other('foo', '/bar', '/baz', mod.SPAN, _class='cls') assert_attr(s, 'class', 'cls') s = mod.link_other('foo', '/bar', '/bar', mod.SPAN, _class='cls') assert_attr(s, 'class', 'cls')
def test_link_other_alternative_wrapper(): s = mod.link_other('foo', '/bar', '/bar', mod.SPAN) assert_tag(s, 'span') assert_content(s, 'foo')
def test_link_other(): s = mod.link_other('foo', '/bar', '/baz') assert_tag(s, 'a') assert_attr(s, 'href', '/bar') s = mod.link_other('foo', '/bar', '/bar') assert s == '<span>foo</span>'