def render(self, show_title=False, extra_css=None, closing_tag=True, tag='a', **kw): title = kw.get('title') or self.title attrs = { 'title': title, 'class': ' '.join(['icon', extra_css or '']).strip(), } if tag == 'a': attrs['href'] = '#' attrs.update(kw) attrs = ew._Jinja2Widget().j2_attrs(attrs) visible_title = u'' if show_title: visible_title = u' {}'.format(Markup.escape(title)) closing_tag = u'</{}>'.format(tag) if closing_tag else u'' icon = u'<{} {}><i class="{}"></i>{}{}'.format(tag, attrs, self.css, visible_title, closing_tag) return Markup(icon)
def render_attrs(self): """Return extra_attrs formatted in a way that allows inserting into html tag""" return ew._Jinja2Widget().j2_attrs(self.extra_attrs or {})