def paginate_link_tag(item): """ Create an A-HREF tag that points to another page usable in paginate. """ a_tag = Page.default_link_tag(item) if item['type'] == 'current_page': return make_html_tag('li', a_tag, **{'class': 'blue white-text'}) return make_html_tag('li', a_tag)
def paginate_link_tag(item): """ Create an A-HREF tag that points to another page usable in paginate. """ item['attrs'] = {'class': 'page-link'} a_tag = paginate.Page.default_link_tag(item) if item['type'] == 'current_page': return paginate.make_html_tag('li', paginate.make_html_tag('a', a_tag), **{"class": "page-item active"}) return paginate.make_html_tag("li", a_tag, **{"class": "page-item"})
def default_link_tag(item): # based on the base class implementation, but wrapping results in <li>, and with different handling of current_page text = item['value'] if item['type'] == 'current_page': # we need active on the li and can thus not use curpage_attr return '''<li class="active"><span>%s</span></li>''' % text if not item['href'] or item['type'] == 'span': if item['attrs']: text = paginate.make_html_tag('span', **item['attrs']) + text + '</span>' else: target_url = item['href'] text = paginate.make_html_tag('a', text=text, href=target_url, **item['attrs']) return '''<li>%s</li>''' % text
def default_link_tag(item, extra_attributes=None): """ Create an A-HREF tag that points to another page. """ extra_attributes = extra_attributes or {} text = item["value"] target_url = item["href"] a_html = make_html_tag("a", text=text, href=target_url, **item["attrs"]) return make_html_tag("li", a_html, **extra_attributes)
def test_make_html_tag(): """Test the make_html_tag() function""" eq_(paginate.make_html_tag('div'), '<div>') eq_(paginate.make_html_tag('a',href="/another/page"), '<a href="/another/page">') eq_(paginate.make_html_tag('a',href="/another/page",text="foo"), '<a href="/another/page">foo</a>') eq_(paginate.make_html_tag('a',href=u"/другой/страница",text="foo"), u'<a href="/другой/страница">foo</a>') eq_(paginate.make_html_tag('a',href="/another/page",text="foo",onclick="$('#mydiv').focus();"), """<a href="/another/page" onclick="$('#mydiv').focus();">foo</a>""") eq_(paginate.make_html_tag('span',style='green'), '<span style="green">') eq_(paginate.make_html_tag('div', _class='red', id='maindiv'), '<div class="red" id="maindiv">')
def test_make_html_tag(): """Test the make_html_tag() function""" eq_(paginate.make_html_tag("div"), "<div>") eq_(paginate.make_html_tag("a", href="/another/page"), '<a href="/another/page">') eq_(paginate.make_html_tag("a", href="/another/page", text="foo"), '<a href="/another/page">foo</a>') eq_(paginate.make_html_tag("a", href=u"/другой/страница", text="foo"), u'<a href="/другой/страница">foo</a>') eq_( paginate.make_html_tag("a", href="/another/page", text="foo", onclick="$('#mydiv').focus();"), """<a href="/another/page" onclick="$('#mydiv').focus();">foo</a>""", ) eq_(paginate.make_html_tag("span", style="green"), '<span style="green">') eq_(paginate.make_html_tag("div", _class="red", id="maindiv"), '<div class="red" id="maindiv">')
def test_make_html_tag(): """Test the make_html_tag() function""" assert paginate.make_html_tag('div') == '<div>' assert paginate.make_html_tag('a', href="/another/page") == '<a href="/another/page">' assert paginate.make_html_tag('a', href="/another/page", text="foo") == '<a href="/another/page">foo</a>' assert paginate.make_html_tag('a', href=u"/другой/страница", text="foo") == u'<a href="/другой/страница">foo</a>' assert paginate.make_html_tag('a', href="/another/page", text="foo", onclick="$('#mydiv').focus();") == """<a href="/another/page" onclick="$('#mydiv').focus();">foo</a>""" assert paginate.make_html_tag('span', style='green') == '<span style="green">' assert paginate.make_html_tag('div', _class='red', id='maindiv') == '<div class="red" id="maindiv">'
def test_make_html_tag(): """Test the make_html_tag() function""" eq_(paginate.make_html_tag('div'), '<div>') eq_(paginate.make_html_tag('a', href="/another/page"), '<a href="/another/page">') eq_(paginate.make_html_tag('a', href="/another/page", text="foo"), '<a href="/another/page">foo</a>') eq_( paginate.make_html_tag('a', href="/another/page", text="foo", onclick="$('#mydiv').focus();"), """<a href="/another/page" onclick="$('#mydiv').focus();">foo</a>""") eq_(paginate.make_html_tag('span', style='green'), '<span style="green">') eq_(paginate.make_html_tag('div', _class='red', id='maindiv'), '<div class="red" id="maindiv">')