Example #1
0
def navsection_question_common(question, user):
    """
    Common sections:

    [link to page root]
        * Submissions
    """
    links = [
        a(_('Submissions'), href=question.get_absolute_url('submissions'))
    ]
    return navsection(question.title, links, href=question.get_absolute_url())
Example #2
0
def index_view(request):
    urls = []
    for item in list(urlpatterns)[1:]:
        name = item._regex[1:-1]
        urls.append(a(name.title(), href=name))

    ctx = {
        'content_title': 'Codeschool components overview',
        'content_body': div()[h2('List of components'),
                              ul(map(li, urls))],
    }
    return render(request, 'base.jinja2', ctx)
Example #3
0
def index_view(request):
    urls = []
    for item in list(urlpatterns)[1:]:
        name = item._regex[1:-1]
        urls.append(a(name.title(), href=name))

    ctx = {
        'content_title': 'Codeschool components overview',
        'content_body': div()[
            h2('List of components'),
            ul(map(li, urls))
        ],
    }
    return render(request, 'base.jinja2', ctx)
def test_nested_tags():
    tag = div(class_='title')[h1('foobar'), a('bar', href='foo/')]
    html = tag.render(None)
    assert html == '<div class="title"><h1>foobar</h1><a href="foo/">bar</a></div>'
Example #5
0
 def a(self):
     return a(class_='cls', href='url')['click me']
Example #6
0
 def test_nested_withs(self):
     with div(class_='root') as elem:
         with div:
             +a('foo')
     assert str(elem) == '<div class="root"><div><a>foo</a></div></div>'
Example #7
0
 def test_with_syntax(self):
     with div as elem:
         +a('foo')
     assert str(elem) == '<div><a>foo</a></div>'
Example #8
0
 def test_tag_call_is_a_constructor(self, a):
     new = a(class_='foo', id='id')
     assert new.classes == ['cls', 'foo']
     assert str(new) == '<a id="id" class="cls foo" href="url">click me</a>'
Example #9
0
 def a(self):
     return a(class_='cls1 cls2', id='id', href='url')['click me']