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')
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')
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)
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)