当前位置: 首页>>代码示例>>Python>>正文


Python tags.span函数代码示例

本文整理汇总了Python中twisted.web.template.tags.span函数的典型用法代码示例。如果您正苦于以下问题:Python span函数的具体用法?Python span怎么用?Python span使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了span函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sourceFragmentElement

    def test_sourceFragmentElement(self):
        """
        L{_SourceFragmentElement} renders source lines at and around the line
        number indicated by a frame object.
        """
        element = _SourceFragmentElement(
            TagLoader(tags.div(
                    tags.span(render="lineNumber"),
                    tags.span(render="sourceLine"),
                    render="sourceLines")),
            self.frame)

        source = [
            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}message = '
            u'"This is a problem"',

            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}raise Exception(message)',
            u'# Figure out the line number from which the exception will be '
            u'raised.',
        ]
        d = flattenString(None, element)
        d.addCallback(
            self.assertEqual,
            ''.join([
                    '<div class="snippet%sLine"><span>%d</span><span>%s</span>'
                    '</div>' % (
                        ["", "Highlight"][lineNumber == 1],
                        self.base + lineNumber,
                        (u" \N{NO-BREAK SPACE}" * 4 + sourceLine).encode(
                            'utf-8'))
                    for (lineNumber, sourceLine)
                    in enumerate(source)]))
        return d
开发者ID:ali-hallaji,项目名称:twisted,代码行数:33,代码来源:test_util.py

示例2: getSignInLink

 def getSignInLink(self):
     return tags.span(
         tags.a(
             tags.span("Persona Sign-in", class_="persona-link-text"),
             href="#login", id="persona-login-link",
             class_="persona-button dark"),
         id="persona-login")
开发者ID:mindpool,项目名称:www.mindpool.io,代码行数:7,代码来源:basefragments.py

示例3: test

 def test(missing):
     plating = Plating(tags=tags.span(slot(Plating.CONTENT)))
     @plating.routed(self.app.route("/"),
                     tags.span(tags.span(render=missing)))
     def no(request):
         return {}
     self.get(b"/")
     [fe] = self.flushLoggedErrors(FlattenerError)
     self.assertIsInstance(fe.value.args[0], MissingRenderMethod)
开发者ID:glasnt,项目名称:klein,代码行数:9,代码来源:test_plating.py

示例4: getAuthedLink

 def getAuthedLink(self, account):
     return tags.span(
         tags.a(
             tags.span(
                 account.getDisplayName(), class_="persona-link-text"),
             href="/members/account", class_="account-link"),
         " | ",
         tags.a(
             tags.span("Sign out", class_="persona-link-text"),
             href="#logout", id="persona-logout-link"),
         id="member-links")
开发者ID:mindpool,项目名称:www.mindpool.io,代码行数:11,代码来源:basefragments.py

示例5: test_presentation_only_json

 def test_presentation_only_json(self):
     """
     Slots marked as "presentation only" will not be reflected in the
     output.
     """
     plating = Plating(tags=tags.span(slot("title")),
                       presentation_slots={"title"})
     @plating.routed(self.app.route("/"),
                     tags.span(slot("data")))
     def justJson(request):
         return {"title": "uninteresting", "data": "interesting"}
     request, written = self.get(b"/?json=1")
     self.assertEqual(json.loads(written.decode("utf-8")),
                      {"data": "interesting"})
开发者ID:glasnt,项目名称:klein,代码行数:14,代码来源:test_plating.py

示例6: test_sourceLineElement

 def test_sourceLineElement(self):
     """
     L{_SourceLineElement} renders a source line and line number.
     """
     element = _SourceLineElement(
         TagLoader(tags.div(
                 tags.span(render="lineNumber"),
                 tags.span(render="sourceLine"))),
         50, "    print 'hello'")
     d = flattenString(None, element)
     expected = (
         u"<div><span>50</span><span>"
         u" \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}print 'hello'</span></div>")
     d.addCallback(
         self.assertEqual, expected.encode('utf-8'))
     return d
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:16,代码来源:test_util.py

示例7: getCities

 def getCities(self):
     elements = []
     for index, city in enumerate(sorted(config.officeCities)):
         if index >= 1:
             elements.append("·")
         elements.append(tags.span(city, class_="city"))
     return elements
开发者ID:mindpool,项目名称:www.mindpool.io,代码行数:7,代码来源:fragments.py

示例8: test_template_numbers

    def test_template_numbers(self):
        """
        Data returned from a plated method may include numeric types (integers,
        floats, and possibly longs), which although they are not normally
        serializable by twisted.web.template, will be converted by plating into
        their decimal representation.
        """
        @page.routed(
            self.app.route("/"),
            tags.div(
                tags.span(slot("anInteger")),
                tags.i(slot("anFloat")),
                tags.b(slot("anLong")),
            ),
        )
        def plateMe(result):
            return {"anInteger": 7,
                    "anFloat": 3.2,
                    "anLong": 0x10000000000000001}

        request, written = self.get(b"/")

        self.assertIn(b"<span>7</span>", written)
        self.assertIn(b"<i>3.2</i>", written)
        self.assertIn(b"<b>18446744073709551617</b>", written)
开发者ID:twisted,项目名称:klein,代码行数:25,代码来源:test_plating.py

示例9: maybeShortenList

def maybeShortenList(system, label, lst, idbase):
    lst2 = []
    for name in lst:
        o = system.allobjects.get(name)
        if o is None or o.isVisible:
            lst2.append(name)
    lst = lst2
    if not lst:
        return None
    def one(item):
        if item in system.allobjects:
            return taglink(system.allobjects[item])
        else:
            return item
    def commasep(items):
        r = []
        for item in items:
            r.append(one(item))
            r.append(', ')
        del r[-1]
        return r
    p = [label]
    if len(lst) <= 5 or not system.options.htmlshortenlists:
        p.extend(commasep(lst))
    else:
        p.extend(commasep(lst[:3]))
        q = [', ']
        q.extend(commasep(lst[3:]))
        q.append(tags.span(class_='showIfJS')[
            ' ',
            tags.a(href="#",
                   onclick="showAndHide('%s');"%idbase,
                   class_="jslink")
            ['(hide last %d again)'%len(lst[3:])]])
        p.append(tags.span(id=idbase, class_='hideIfJS')[q])
        p.append(tags.span(id=idbase+'Link', class_='showIfJS')[
            ' ',
            tags.a(href="#",
                   onclick="hideAndShow('%s');"%idbase,
                   class_="jslink")
            ['... and %d more'%len(lst[3:])]])
    return p
开发者ID:chevah,项目名称:pydoctor,代码行数:42,代码来源:__init__.py

示例10: test_failureElementType

 def test_failureElementType(self):
     """
     The I{type} renderer of L{FailureElement} renders the failure's
     exception type.
     """
     element = FailureElement(
         self.failure, TagLoader(tags.span(render="type")))
     d = flattenString(None, element)
     d.addCallback(
         self.assertEqual, "<span>exceptions.Exception</span>")
     return d
开发者ID:ali-hallaji,项目名称:twisted,代码行数:11,代码来源:test_util.py

示例11: test_failureElementValue

 def test_failureElementValue(self):
     """
     The I{value} renderer of L{FailureElement} renders the value's exception
     value.
     """
     element = FailureElement(
         self.failure, TagLoader(tags.span(render="value")))
     d = flattenString(None, element)
     d.addCallback(
         self.assertEqual, b'<span>This is a problem</span>')
     return d
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:11,代码来源:test_util.py

示例12: render

    def render(self, request):
        setRequestCatalog(request)
        form = self.form(request)
        request.write('<!DOCTYPE html>\n')
        if request.method == "POST" and form.validate():
            content = tags.span("Form Valid!")
        else:
            content = FormElement(form)

        done = flatten(request, Layout(content), request.write)
        done.addCallback(lambda r: request.finish())
        return server.NOT_DONE_YET
开发者ID:veloutin,项目名称:txwtf,代码行数:12,代码来源:hoorj.py

示例13: test_prime_directive_return

 def test_prime_directive_return(self):
     """
     Nothing within these Articles Of Federation shall authorize the United
     Federation of Planets to alter the return value of a callable by
     applying a decorator to it...
     """
     exact_result = {"ok": "some nonsense value"}
     @page.routed(self.app.route("/"),
                  tags.span(slot("ok")))
     def plateMe(request):
         return exact_result
     self.assertIdentical(plateMe(None), exact_result)
开发者ID:glasnt,项目名称:klein,代码行数:12,代码来源:test_plating.py

示例14: test_template_html

 def test_template_html(self):
     """
     Rendering a L{Plating.routed} decorated route results in templated
     HTML.
     """
     @page.routed(self.app.route("/"),
                  tags.span(slot("ok")))
     def plateMe(request):
         return {"ok": "test-data-present"}
     request, written = self.get(b"/")
     self.assertIn(b'<span>test-data-present</span>', written)
     self.assertIn(b'<title>default title unchanged</title>', written)
开发者ID:glasnt,项目名称:klein,代码行数:12,代码来源:test_plating.py

示例15: entry_rendered

        def entry_rendered(entry):
            if entry.system_entry:
                attrs_entry = attrs_entry_system
            else:
                attrs_entry = attrs_entry_user

            return tags.div(
                tags.span(
                    str(entry.created),
                    u", ",
                    entry.author,
                    **attrs_timestamp
                ),
                ":",
                tags.br(),
                tags.span(
                    entry.text,
                    **attrs_entry_text
                ),
                **attrs_entry
            )
开发者ID:EntropyWorks,项目名称:ranger-ims,代码行数:21,代码来源:incident.py


注:本文中的twisted.web.template.tags.span函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。