Exemple #1
0
    def _to_list(self, l):
        l.extend((u'<', self.__tag__))
        for name, value in self.__attributes__.iteritems():
            l.extend((u' ', name, u'="', escape(value), u'"'))
        l.append(u'>')

        for child in self.__children__:
            x_base._render_child_to_list(child, l)

        l.extend((u'</', self.__tag__, u'>'))
Exemple #2
0
    def _to_list(self, l):
        l.extend((u'<', self.__tag__))
        for name, value in self.__attributes__.iteritems():
            l.extend((u' ', name, u'="', escape(value), u'"'))
        l.append(u'>')

        for child in self.__children__:
            x_base._render_child_to_list(child, l)

        l.extend((u'</', self.__tag__, u'>'))
Exemple #3
0
    def to_string(self):
        out = [u'<', self.__tag__]
        for name, value in self.__attributes__.iteritems():
            out.extend((u' ', name, u'="', escape(value), u'"'))
        out.append(u'>')

        for child in self.__children__:
            out.append(x_base.render_child(child))

        out.extend((u'</', self.__tag__, u'>'))
        return u''.join(out)
Exemple #4
0
    def _to_list(self, l):
        l.extend(('<', self.__tag__))
        for name, value in self.__attributes__.items():
            name, value = self._handle_attribute(name, value)
            l.extend((' ', name, '="', escape(value), '"'))
        l.append('>')

        for child in self.__children__:
            x_base._render_child_to_list(child, l)

        l.extend(('</', self.__tag__, '>'))
Exemple #5
0
    def _to_list(self, l):
        l.extend(('<', self.__tag__))
        for name, value in self.__attributes__.items():
            name, value = self._handle_attribute(name, value)
            l.extend((' ', name, '="', escape(value), '"'))
        l.append('>')

        for child in self.__children__:
            x_base._render_child_to_list(child, l)

        l.extend(('</', self.__tag__, '>'))
Exemple #6
0
    def handle_data(self, data):
        data = self._normalize_data_whitespace(data,
                                               self.last_thing_was_python,
                                               self.next_thing_is_python)
        if not data:
            return

        self.start_element()
        self.handle_close_if()

        # XXX XXX mimics old pyxl, but this is gross and likely wrong. I'm pretty sure we actually
        # want %r instead of this crazy quote substitution and u"%s".
        data = data.replace('"', '\\"')
        if data != escape(data):
            self.output.append('html.rawhtml(u"%s"), ' % data)
        else:
            self.output.append('u"%s", ' % data)

        self.last_thing_was_python = False
        self.last_thing_was_close_if_tag = False
Exemple #7
0
 def _render_child_to_list(child, l):
     if isinstance(child, x_base): child._to_list(l)
     elif child is not None: l.append(escape(child))
Exemple #8
0
 def _to_list(self, l):
     l.extend((u'<', self.__tag__))
     for name, value in self.__attributes__.iteritems():
         l.extend((u' ', name, u'="', escape(value), u'"'))
     l.append(u' />')
Exemple #9
0
 def to_string(self):
     out = [u'<', self.__tag__]
     for name, value in self.__attributes__.iteritems():
         out.extend((u' ', name, u'="', escape(value), u'"'))
     out.append(u' />')
     return u''.join(out)
Exemple #10
0
 def _render_child_to_list(child, l):
     if isinstance(child, x_base): child._to_list(l)
     elif child is not None: l.append(escape(child))
Exemple #11
0
 def _to_list(self, l):
     l.extend((u'<', self.__tag__))
     for name, value in self.__attributes__.iteritems():
         l.extend((u' ', name, u'="', escape(value), u'"'))
     l.append(u' />')
Exemple #12
0
 def render_child(child):
     child_type = type(child)
     if issubclass(child_type, x_base): return child.to_string()
     if child_type is rawhtml: return child.render()
     if child_type is type(None): return u''
     return escape(child)