本文整理汇总了Python中webhelpers.html.HTML类的典型用法代码示例。如果您正苦于以下问题:Python HTML类的具体用法?Python HTML怎么用?Python HTML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTML类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: radio
def radio(name, value, checked=False, label=None, **attrs):
"""Create a radio button.
Arguments:
``name`` -- the field's name.
``value`` -- the value returned to the application if the button is
pressed.
``checked`` -- true if the button should be initially pressed.
``label`` -- a text label to display to the right of the button.
The id of the radio button will be set to the name + '_' + value to
ensure its uniqueness. An ``id`` keyword arg overrides this. (Note
that this behavior is unique to the ``radio()`` helper.)
To arrange multiple radio buttons in a group, see
webhelpers.containers.distribute().
"""
_set_input_attrs(attrs, "radio", name, value)
if checked:
attrs["checked"] = "checked"
if not "id" in attrs:
attrs["id"] = '%s_%s' % (name, _make_safe_id_component(value))
widget = HTML.input(**attrs)
if label:
widget = HTML.label(widget, label)
return widget
开发者ID:gjhiggins,项目名称:WebHelpers2,代码行数:29,代码来源:tags.py
示例2: get_audio_tag
def get_audio_tag(self, request):
from webhelpers.html import HTML
static_path = self.get_static_path(request)
source_tag = HTML.tag('source', type_='audio/mp3', src=static_path)
audio_tag = HTML.tag('audio', controls='controls', c=[source_tag])
div_tag = HTML.tag('div', class_='mp3', c=[audio_tag])
return div_tag
开发者ID:digideskio,项目名称:sasha,代码行数:7,代码来源:MP3Audio.py
示例3: error_container
def error_container(name, as_text=False):
return HTML.tag(
"span",
class_="error %s hidden" % ("fa fa-arrow-circle-down as-text" if as_text else "fa fa-exclamation-circle"),
c=HTML.tag("span"),
**{"data-name": name}
)
开发者ID:nagites,项目名称:travelcrm,代码行数:7,代码来源:common.py
示例4: _get_update_details
def _get_update_details(self, update):
details = ''
if update['status'] == 'stable':
if update.get('updateid'):
details += HTML.tag('a', c=update['updateid'], href='%s/%s' % (
self._prod_url, update['updateid']))
if update.get('date_pushed'):
details += HTML.tag('br') + update['date_pushed']
else:
details += 'In process...'
elif update['status'] == 'pending' and update.get('request'):
details += 'Pending push to %s' % update['request']
details += HTML.tag('br')
details += HTML.tag('a', c="View update details >",
href="%s/%s" % (self._prod_url,
update['title']))
elif update['status'] == 'obsolete':
for comment in update['comments']:
if comment['author'] == 'bodhi':
if comment['text'].startswith('This update has been '
'obsoleted by '):
details += \
'Obsoleted by %s' % HTML.tag(
'a', href='%s/%s' % (
self._prod_url, update['title']),
c=comment['text'].split()[-1])
return details
开发者ID:Fale,项目名称:fedora-packages,代码行数:27,代码来源:bodhiconnector.py
示例5: test_unclosed_tag
def test_unclosed_tag():
result = HTML.form(_closed=False)
print result
eq_(u'<form>', result)
result = HTML.form(_closed=False, action="hello")
eq_(u'<form action="hello">', result)
开发者ID:gjhiggins,项目名称:WebHelpers2,代码行数:7,代码来源:test_html.py
示例6: error_container
def error_container(name, as_text=False):
return HTML.tag(
'span',
class_='error %s hidden'
% ('fa fa-arrow-circle-down as-text' if as_text else 'fa fa-exclamation-circle'),
c=HTML.tag('span'),
**{'data-name': name}
)
开发者ID:alishir,项目名称:tcr,代码行数:8,代码来源:common.py
示例7: _pagerlink
def _pagerlink(self, page, text):
# Let the url_for() from webhelpers create a new link and set
# the variable called 'page_param'. Example:
# You are in '/foo/bar' (controller='foo', action='bar')
# and you want to add a parameter 'page'. Then you
# call the navigator method with page_param='page' and
# the url_for() call will create a link '/foo/bar?page=...'
# with the respective page number added.
link_params = {}
# Use the instance kwargs from Page.__init__ as URL parameters
link_params.update(self.kwargs)
# Add keyword arguments from pager() to the link as parameters
link_params.update(self.pager_kwargs)
link_params[self.page_param] = page
# Get the URL generator
if self._url_generator is not None:
url_generator = self._url_generator
else:
try:
import pylons
url_generator = pylons.url.current
except (ImportError, AttributeError):
try:
import routes
url_generator = routes.url_for
config = routes.request_config()
except (ImportError, AttributeError):
raise NotImplementedError("no URL generator available")
else:
# if the Mapper is configured with explicit=True we have to fetch
# the controller and action manually
if config.mapper.explicit:
if hasattr(config, 'mapper_dict'):
for k, v in config.mapper_dict.items():
if k != self.page_param:
link_params[k] = v
# Create the URL to load a certain page
link_url = url_generator(**link_params)
if self.onclick: # create link with onclick action for AJAX
# Create the URL to load the page area part of a certain page (AJAX
# updates)
link_params[self.partial_param] = 1
partial_url = url_generator(**link_params)
try: # if '%s' is used in the 'onclick' parameter (backwards compatibility)
onclick_action = self.onclick % (partial_url,)
except TypeError:
onclick_action = Template(self.onclick).safe_substitute({
"partial_url": partial_url,
"page": page
})
a_tag = HTML.a(text, href=link_url, onclick=onclick_action, **self.link_attr)
else: # return static link
a_tag = HTML.a(text, href=link_url, **self.link_attr)
li_tag = HTML.li(a_tag)
return li_tag
开发者ID:digideskio,项目名称:sasha,代码行数:58,代码来源:Page.py
示例8: contact_type_icon
def contact_type_icon(contact_type):
assert contact_type.key in (u'phone', u'email', u'skype'), \
u"wrong contact type"
if contact_type.key == u'phone':
return HTML.tag('span', class_='fa fa-phone')
elif contact_type.key == u'email':
return HTML.tag('span', class_='fa fa-envelope')
else:
return HTML.tag('span', class_='fa fa-skype')
开发者ID:alishir,项目名称:tcr,代码行数:9,代码来源:common.py
示例9: input_submit_text_button
def input_submit_text_button(text=None, name=None, **html_options):
if text is None:
from pylons.i18n import _
text = _('Save')
if name is not None:
html_options['name'] = name
html_options.setdefault('class_', "btn-text")
html_options.setdefault('value', text)
return HTML.button(c=[HTML.span(text)], **html_options)
开发者ID:nous-consulting,项目名称:ututi,代码行数:10,代码来源:helpers.py
示例10: test_html
def test_html():
a = HTML.a(href='http://mostlysafe\" <tag', c="Bad <script> tag")
eq_(a,
u'<a href="http://mostlysafe" <tag">Bad <script> tag</a>')
img = HTML.img(src='http://some/image.jpg')
eq_(img, u'<img src="http://some/image.jpg" />')
br = HTML.br()
eq_(u'<br />', br)
开发者ID:gjhiggins,项目名称:WebHelpers2,代码行数:10,代码来源:test_html.py
示例11: _range
def _range(self, regexp_match):
html = super(Page, self)._range(regexp_match)
# Convert ..
dotdot = "\.\."
dotdot_link = HTML.li(HTML.a("...", href="#"), class_="disabled")
html = re.sub(dotdot, dotdot_link, html)
# Convert current page
text = "%s" % self.page
current_page_span = str(HTML.span(c=text, **self.curpage_attr))
current_page_link = self._pagerlink(self.page, text, extra_attributes=self.curpage_attr)
return re.sub(current_page_span, current_page_link, html)
开发者ID:fusionx1,项目名称:ckan,代码行数:11,代码来源:helpers.py
示例12: sa_learned
def sa_learned(value):
"indicate learning status"
if not value:
HTML.span(_('N'), class_='negative')
match = LEARN_RE.search(value)
if match:
return (HTML.span(_('Y'), class_='positive') +
literal(' ') + '(%s)' % escape(match.group(1)))
else:
return HTML.span(_('N'), class_='negative')
开发者ID:haugvald,项目名称:baruwa2,代码行数:11,代码来源:helpers.py
示例13: button
def button(context, permision, caption, **kwargs):
html = ""
if context.has_permision(permision):
caption = HTML.tag("span", c=caption)
icon = ""
if "icon" in kwargs:
icon = HTML.tag("span", class_=kwargs.pop("icon"))
button_class = "button _action " + kwargs.pop("class", "")
button_class = button_class.strip()
html = HTML.tag("a", class_=button_class, c=HTML(icon, caption), **kwargs)
return html
开发者ID:nagites,项目名称:travelcrm,代码行数:11,代码来源:common.py
示例14: boolicon
def boolicon(value):
"""Returns boolean value of a value, represented as small html image of true/false
icons
:param value: value
"""
if value:
return HTML.tag('i', class_="icon-ok")
else:
return HTML.tag('i', class_="icon-minus-circled")
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:11,代码来源:helpers.py
示例15: boolicon
def boolicon(value):
"""Returns boolean value of a value, represented as small html image of true/false
icons
:param value: value
"""
if value:
return HTML.tag('img', src=url("/images/icons/accept.png"),
alt=_('True'))
else:
return HTML.tag('img', src=url("/images/icons/cancel.png"),
alt=_('False'))
开发者ID:greenboxindonesia,项目名称:rhodecode,代码行数:13,代码来源:helpers.py
示例16: checkbox
def checkbox(label, name, checked=False, **kwargs):
kwargs['type'] = 'checkbox'
kwargs['name'] = name
if checked:
kwargs['checked'] = 'checked'
kwargs.setdefault('id', name)
return HTML.div(class_='formField checkbox',
id='%s-field' % kwargs['id'],
c=[HTML.label(for_=name, c=[
HTML.input(**kwargs),
HTML.span(class_='labelText', c=[label])
]),
HTML.literal('<form:error name="%s" />' % name)])
开发者ID:nous-consulting,项目名称:ututi,代码行数:13,代码来源:helpers.py
示例17: h1
def h1(title, id=None, tag='h1', **attrs):
"""Returns an <h1> tag that links to itself.
`title` is the text inside the tag.
`id` is the HTML id to use; if none is provided, `title` will be munged
into something appropriate.
"""
if not id:
id = sanitize_id(title)
link = HTML.a(title, href='#' + id, class_='subtle')
return HTML.tag(tag, link, id=id, **attrs)
开发者ID:encukou,项目名称:spline,代码行数:13,代码来源:helpers.py
示例18: _range
def _range(self, regexp_match):
html = super(Page, self)._range(regexp_match)
# Convert ..
dotdot = '<span class="pager_dotdot">..</span>'
dotdot_link = HTML.li(HTML.a('...', href='#'), class_='disabled')
html = re.sub(dotdot, dotdot_link, html)
# Convert current page
text = '%s' % self.page
current_page_span = str(HTML.span(c=text, **self.curpage_attr))
current_page_link = self._pagerlink(self.page, text,
extra_attributes=self.curpage_attr)
return re.sub(current_page_span, current_page_link, html)
开发者ID:HHS,项目名称:ckan,代码行数:13,代码来源:helpers.py
示例19: button
def button(context, permision, caption, **kwargs):
html = ''
if context.has_permision(permision):
caption = HTML.tag('span', c=caption)
icon = ''
if 'icon' in kwargs:
icon = HTML.tag('span', class_=kwargs.pop('icon'))
button_class = "button _action " + kwargs.pop('class', '')
button_class = button_class.strip()
html = HTML.tag(
'a', class_=button_class,
c=HTML(icon, caption), **kwargs
)
return html
开发者ID:alishir,项目名称:tcr,代码行数:14,代码来源:common.py
示例20: js_obfuscate
def js_obfuscate(content):
"""Obfuscate data in a Javascript tag.
Example::
>>> js_obfuscate("<input type='hidden' name='check' value='valid' />")
literal(u'<script type="text/javascript">\\n//<![CDATA[\\neval(unescape(\\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%69%6e%70%75%74%20%74%79%70%65%3d%27%68%69%64%64%65%6e%27%20%6e%61%6d%65%3d%27%63%68%65%63%6b%27%20%76%61%6c%75%65%3d%27%76%61%6c%69%64%27%20%2f%3e%27%29%3b\\'))\\n//]]>\\n</script>')
"""
doc_write = "document.write('%s');" % content
obfuscated = ''.join(['%%%x' % ord(x) for x in doc_write])
complete = "eval(unescape('%s'))" % obfuscated
cdata = HTML.cdata("\n", complete, "\n//")
return HTML.script("\n//", cdata, "\n", type="text/javascript")
开发者ID:dummyanni,项目名称:Bachelor-Thesis,代码行数:14,代码来源:tools.py
注:本文中的webhelpers.html.HTML类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论