本文整理汇总了Python中xierpa3.toolbox.transformer.TX.dataAttribute2Html5Attribute方法的典型用法代码示例。如果您正苦于以下问题:Python TX.dataAttribute2Html5Attribute方法的具体用法?Python TX.dataAttribute2Html5Attribute怎么用?Python TX.dataAttribute2Html5Attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xierpa3.toolbox.transformer.TX
的用法示例。
在下文中一共展示了TX.dataAttribute2Html5Attribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: script
# 需要导入模块: from xierpa3.toolbox.transformer import TX [as 别名]
# 或者: from xierpa3.toolbox.transformer.TX import dataAttribute2Html5Attribute [as 别名]
def script(self, charset='UTF-8', type='text/javascript', **args):
"""
The <code>br</code> tag inserts a single line break.<br/>
Defines a script, such as a JavaScript. Note that if @src is used, then no <code>self._script()</code> must be used.
The count attribute is not standard XHTML. It indicates the number of <code>br</code> to repeat.<br/>
<seealso><www href="http://www.w3schools.com/tags/tag_script.asp" target="external"/></seealso>
<python>
self.script()<br/>
...<br/>
self._script()
</python>
"""
#
# Build script. Note that if @src is used, then no self._script()
# must be used.
#
r = self.result.peek()
r.write(u'<script')
# Make sure to write "UTF-8" instead of "utf-8" since FireFox 2.0.0.4 will
# ignore the script otherwise.
r.write(u' charset="%s"' % charset.upper())
r.write(u' type="%s"' % type)
language = args.get(u'language')
if language is not None:
r.write(u' language="%s"' % language)
for key, value in args.items():
r.write(u' %s="%s"' % (TX.dataAttribute2Html5Attribute(key), value))
src = args.get(u'src')
if src is not None:
r.write(u'></script>\n')
else:
self._pushTag(u'script')
r.write(u'>\n')
示例2: get_attribute_exceptions
# 需要导入模块: from xierpa3.toolbox.transformer import TX [as 别名]
# 或者: from xierpa3.toolbox.transformer.TX import dataAttribute2Html5Attribute [as 别名]
def get_attribute_exceptions(self, key, value):
u"""
The <code>get_attribute_exceptions</code> method writes the attribute, and checks on naming differences between
the Xierpa attributes and HTML attributes.
"""
# Boolean attributes.
key = TX.dataAttribute2Html5Attribute(key)
if key in self.BOOLEAN_ATTRIBUTES:
if TX.value2Bool(value): # Can be boolean or text boolean
self.write_attribute(key, self.BOOLEAN_ATTRIBUTES[key])
else:
# Some exceptions.
if key.startswith('html'):
key = key[3:]
if key == 'class_':
key = 'class'
# elif key == 'src':
# value = self.e.getPath(value)
elif key == 'rowspan':
if int(value) <= 1:
return
elif key == 'colspan':
if int(value) <= 1:
return
elif key == 'xmllang':
key = 'xml:lang'
elif key == 'httpequiv':
key = 'http-equiv'
elif key == 'usemap':
if not value.startswith(u'#'):
value = u'#' + value
# Handle Angular.org attributes that contain underscores, translate them to hyphens
elif key.startswith('ng_'):
key = key.replace('_', '-')
self.write_attribute(key, value)