本文整理汇总了Python中webhelpers.html.HTML.tag方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.tag方法的具体用法?Python HTML.tag怎么用?Python HTML.tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webhelpers.html.HTML
的用法示例。
在下文中一共展示了HTML.tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: error_container
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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}
)
示例2: _get_update_details
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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
示例3: get_audio_tag
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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
示例4: error_container
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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}
)
示例5: contact_type_icon
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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')
示例6: button
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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
示例7: boolicon
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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")
示例8: boolicon
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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'))
示例9: button
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
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
示例10: add_updates_to_builds
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def add_updates_to_builds(self, builds):
"""Update a list of koji builds with the corresponding bodhi updates.
This method makes a single query to bodhi, asking if it knows about
any updates for a given list of koji builds. For builds with existing
updates, the `update` will be added to it's dictionary.
Currently it also adds `update_details`, which is HTML for rendering
the builds update options. Ideally, this should be done client-side
in the template (builds/templates/table_widget.mak).
"""
start = datetime.now()
updates = self.call('get_updates_from_builds', {
'builds': ' '.join([b['nvr'] for b in builds])})
if updates:
# FIXME: Lets stop changing the upstream APIs by putting the
# session id as the first element, and the results in the second.
updates = updates[1]
for build in builds:
if build['nvr'] in updates:
build['update'] = updates[build['nvr']]
status = build['update']['status']
details = ''
# FIXME: ideally, we should just return the update JSON and do
# this logic client-side in the template when the grid data
# comes in.
if status == 'stable':
details = 'Pushed to updates'
elif status == 'testing':
details = 'Pushed to updates-testing'
elif status == 'pending':
details = 'Pending push to %s' % build['update']['request']
details += HTML.tag('br')
details += HTML.tag('a', c="View update details >",
href="%s/%s" % (self._prod_url,
build['update']['title']))
else:
details = HTML.tag('a', c='Push to updates >',
href='%s/new?builds.text=%s' % (
self._prod_url, build['nvr']))
build['update_details'] = details
log.debug(
"Queried bodhi for builds in: %s" % (datetime.now() - start))
示例11: bool2icon
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def bool2icon(value):
"""Returns True/False values represented as small html image of true/false
icons
:param value: bool value
"""
if value is True:
return HTML.tag('img', src=url("/images/icons/accept.png"),
alt=_('True'))
if value is False:
return HTML.tag('img', src=url("/images/icons/cancel.png"),
alt=_('False'))
return value
示例12: country_flag
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def country_flag(country, **kwargs):
if country:
return HTML.tag('img',
src="/public/images/flags/%s.png" % country.code,
title=country.name,
**kwargs)
else:
return None
示例13: _render_form_buttons
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def _render_form_buttons(self):
_ = self.translate
html = []
html.append(HTML.tag("div", _closed=False, class_="row row-fluid"))
if len(self._form._config.get_pages()) > 0:
html.append(HTML.tag("div",
class_="col-sm-3 span3 button-pane"))
html.append(HTML.tag("div", _closed=False,
class_="col-sm-9 span9 button-pane"))
else:
html.append(HTML.tag("div", _closed=False,
class_="col-sm-12 span12 button-pane well-small"))
# Render default buttons if no buttons have been defined for the
# form.
if len(self._form._config._buttons) == 0:
html.append(HTML.tag("button", type="submit",
name="_submit", value="",
class_="btn btn-default hidden-print",
c=_('Submit')))
# If there is a next page than render and additional submit
# button.
if len(self._form.pages) > 1:
html.append(HTML.tag("button", type="submit",
name="_submit", value="nextpage",
class_="btn btn-default hidden-print",
c=_('Submit and proceed')))
else:
for b in self._form._config._buttons:
if b.attrib.get("ignore"):
continue
html.append(HTML.tag("button", _closed=False,
type=b.attrib.get("type") or "submit",
name="_%s" % b.attrib.get("type") or "submit",
value=b.attrib.get("value") or "",
class_=b.attrib.get("class")
or "btn btn-default hidden-print"))
if b.attrib.get("icon"):
html.append(HTML.tag("i", class_=b.attrib.get("icon"),
c=_(b.text)))
html.append(_(b.text))
html.append(HTML.tag("/div", _closed=False))
html.append(HTML.tag("/div", _closed=False))
return literal("").join(html)
示例14: _render_form_start
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def _render_form_start(self):
html = []
html.append(HTML.tag("div", class_="formbar-form", _closed=False))
html.append(HTML.tag("form", _closed=False,
id=self._form._config.id,
role="form",
class_=self._form._config.css,
action=self._form._config.action,
method=self._form._config.method,
autocomplete=self._form._config.autocomplete,
enctype=self._form._config.enctype,
evalurl=self._form._eval_url or ""))
# Add hidden field with csrf_token if this is not None.
if self._form._csrf_token:
html.append(HTML.tag("input",
type="hidden",
name="csrf_token",
value=self._form._csrf_token))
return literal("").join(html)
示例15: _render_tool
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import tag [as 别名]
def _render_tool(self, tool):
tmp = "container:'#%(id)s',action:'dialog_open',url:'%(url)s'"
if tool.with_row:
tmp += ",property:'with_row'"
kwargs = {
'data-options': tmp % {'id': self._id, 'url': tool.url}
}
return HTML.tag(
'a', href='#',
class_='fa %(icon)s easyui-tooltip _action' % {'icon': tool.icon},
title=tool.title,
**kwargs
)