本文整理汇总了Python中nevow.tags.html函数的典型用法代码示例。如果您正苦于以下问题:Python html函数的具体用法?Python html怎么用?Python html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_nested_data
def test_nested_data(self):
def checkContext(ctx, data):
self.assertEqual(data, "inner")
self.assertEqual(ctx.locate(inevow.IData, depth=2), "outer")
return 'Hi'
tag = tags.html(data="outer")[tags.span(render=lambda ctx,data: ctx.tag, data="inner")[checkContext]]
self.assertEqual(self.render(tag), "<html><span>Hi</span></html>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:7,代码来源:test_flatstan.py
示例2: __init__
def __init__(self, ctx, restWriter, key, srcId):
self.restWriter = restWriter
form = iformal.IForm( ctx )
u = formal_widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ).child('_submit')
self.destId=srcId + '-dest'
formId=srcId + '-form'
stan = T.html()[
T.head()[
T.script(type="text/javascript")["""
function ReSTTranslate() {
dest = document.getElementById('%(destId)s');
form = document.getElementById('%(formId)s');
src = parent.document.getElementById('%(srcId)s');
dest.value = src.value;
form.submit();
}
"""%{'srcId':srcId, 'destId':self.destId, 'formId':formId}]
],
T.body()[
T.form(id=formId, method="POST", action=u)[
T.input(type="hidden", name=self.destId, id=self.destId)
],
T.script(type="text/javascript")["ReSTTranslate();"],
],
]
self.docFactory = loaders.stan(stan)
开发者ID:timparkin,项目名称:into-the-light,代码行数:30,代码来源:richtext.py
示例3: setUp
def setUp(self):
self.d = Deferred()
self.d2 = Deferred()
self.r = rend.Page(docFactory=loaders.stan(
tags.html(data=self.data_later)[
'Hello ', str, ' and '
'goodbye ',str,
tags.span(data=self.data_later2, render=str)]))
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_later.py
示例4: test_precompileDoesntChangeOriginal
def test_precompileDoesntChangeOriginal(self):
doc = tags.html(data="foo")[tags.p['foo'], tags.p['foo']]
result = self.render(doc, precompile=True)
rendered = self.render(result)
self.assertEqual(len(doc.children), 2)
self.assertEqual(rendered, "<html><p>foo</p><p>foo</p></html>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_flatstan.py
示例5: mapHtml
def mapHtml():
width = 600
height = 900
dots = []
for measurement in UpdatingMeasurements().measurements:
try:
speed = float(measurement['speed'])
except ValueError:
print "no speed", measurement
continue
color = "#%02x%02x%02x" % (interp(speed, 50, 0, 0, 255),
interp(speed, 40, 80, 0, 255),
0)
pos = (interp(float(measurement['longitude']), -122.72, -121.50, 0, width),
interp(float(measurement['latitude']), 38.41, 36.93, 0, height))
dotText = u'\u2739'
if random.random() > .9:
dotText += ' %d' % speed
dots.append(
T.div(style="color: %s; position: absolute; left: %spx; top: %spx" %
(color, pos[0], pos[1]))[dotText])
page = [T.raw('''<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'''),
T.html(xmlns="http://www.w3.org/1999/xhtml")[
T.head[T.style[T.raw('''
* {
font-size: 90%;
}
''')]],
T.body[
T.div(style="width: %spx; height: %spx" % (width, height))[
dots
]]]]
return flat.flatten(page)
开发者ID:drewp,项目名称:freeway,代码行数:39,代码来源:map_report.py
示例6: test_cloning
def test_cloning(self):
def data_foo(context, data): return [{'foo':'one'}, {'foo':'two'}]
# tests nested lists without precompilation (precompilation flattens the lists)
def render_test(context, data):
return tags.ul(render=rend.sequence)[
tags.li(pattern='item')[
'foo', (((tags.invisible(data=tags.directive('foo'), render=str),),),)
]
]
# tests tags inside attributes (weird but useful)
document = tags.html(data=data_foo)[
tags.body[
tags.ul(render=rend.sequence)[
tags.li(pattern='item')[
tags.a(href=('test/', tags.invisible(data=tags.directive('foo'), render=str)))['link']
]
],
render_test
]
]
document=self.render(document, precompile=True)
self.assertEqual(self.render(document), '<html><body><ul><li><a href="test/one">link</a></li><li><a href="test/two">link</a></li></ul><ul><li>fooone</li><li>footwo</li></ul></body></html>')
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:24,代码来源:test_flatstan.py
示例7: exceptblock
import warnings
from zope.interface import implements
from twisted.python import components
from nevow.util import Deferred, DeferredList, getPOSTCharset
from nevow import inevow, tags
from nevow.context import WovenContext
import formless
from formless.formutils import enumerate
from formless import iformless
faketag = tags.html()
def exceptblock(f, handler, exception, *a, **kw):
try:
result = f(*a, **kw)
except exception, e:
return handler(e)
if isinstance(result, Deferred):
def _(fail):
fail.trap(exception)
return handler(fail.value)
return result.addErrback(_)
else:
return result
开发者ID:StetHD,项目名称:nevow,代码行数:29,代码来源:processors.py
示例8: test_deferredSlot
def test_deferredSlot(self):
self.render(tags.html().fillSlots('bar', defer.succeed(None))(foo=tags.slot('bar'))["Bar"],
wantDeferred=True).addCallback(
lambda val: self.assertEqual(val, "<html>Bar</html>"))
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:4,代码来源:test_flatstan.py
示例9: test_deepSlot
def test_deepSlot(self):
val = self.render(tags.html().fillSlots('bar', lambda c,d: None)(foo=tags.slot('bar'))["Bar"])
self.assertEqual(val, "<html>Bar</html>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:3,代码来源:test_flatstan.py
示例10: test_simple
def test_simple(self):
val = self.render(tags.html(foo=None)["Bar"])
self.assertEqual(val, "<html>Bar</html>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:3,代码来源:test_flatstan.py
示例11: test_nested
def test_nested(self):
val = self.render(tags.html(src=entities.quot)[entities.amp])
self.assertEqual(val, '<html src=""">&</html>')
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:3,代码来源:test_flatstan.py
示例12: test_nestedTags
def test_nestedTags(self):
self.assertEquals(
ten.flatten(
tags.html(hi='there')[
tags.body[ 42 ]]),
'<html hi="there"><body>42</body></html>')
开发者ID:StetHD,项目名称:nevow,代码行数:6,代码来源:test_flatten.py
示例13: test_slot
def test_slot(self):
val = self.render(tags.html().fillSlots('bar', None)(foo=tags.slot('bar'))["Bar"])
self.assertEquals(val, "<html>Bar</html>")
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:3,代码来源:test_flatstan.py
示例14: _html_fragment
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<div xmlns:n="http://nevow.com/ns/nevow/0.1" >""" + restValue + '</div>'
test = loaders.xmlstr(xml, ignoreDocType=True).load()
except Exception, e:
restValue = "HTML Validation Error: please check any raw HTML blocks."
stan = T.html()[
T.head()[
T.style(type="text/css")["""
.system-message {border: 1px solid red; background-color: #FFFFDD; margin: 5px; padding: 5px;}
.system-message-title { font-weight: bold;}
"""
]
],
T.body()[
T.div()[
T.xml(restValue)
]
],
]
self.docFactory = loaders.stan(stan)
return self
def _html_fragment(self, input_string, writer=None, writer_name=None):
return restsupport.htmlFragment(input_string, writer=writer, writer_name=writer_name)
开发者ID:timparkin,项目名称:into-the-light,代码行数:30,代码来源:richtext.py
注:本文中的nevow.tags.html函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论