Edgewall Software

Ticket #101: genshi-xinclude-parse-attr.patch

File genshi-xinclude-parse-attr.patch, 1.9 KB (added by djc@…, 17 years ago)

Patch to add support for XInclude parse attribute

  • filters.py

    old new  
    137137        @param stream: the markup event stream to filter
    138138        @param ctxt: the template context
    139139        """
     140        from genshi.template import MarkupTemplate, TextTemplate
    140141        from genshi.template import TemplateError, TemplateNotFound
    141142
    142143        ns_prefixes = []
    143144        in_fallback = False
    144         include_href, fallback_stream = None, None
     145        include_href, parse, fallback_stream = None, None, None
    145146        namespace = self.NAMESPACE
    146147
    147148        for kind, data, pos in stream:
     
    150151                tag, attrib = data
    151152                if tag.localname == 'include':
    152153                    include_href = attrib.get('href')
     154                    parse = attrib.get('parse')
    153155                elif tag.localname == 'fallback':
    154156                    in_fallback = True
    155157                    fallback_stream = []
     
    160162                        if not include_href:
    161163                            raise TemplateError('Include misses required '
    162164                                                'attribute "href"')
     165                        if parse == 'xml': cls = MarkupTemplate
     166                        elif parse == 'text': cls = TextTemplate
     167                        else: raise TemplateError('Unknown value "%s" for '
     168                                                 'attribute "parse"' %
     169                                                 repr(parse))
    163170                        template = self.loader.load(include_href,
    164                                                     relative_to=pos[0])
     171                                                    relative_to=pos[0],
     172                                                    cls=cls)
    165173                        for event in template.generate(ctxt):
    166174                            yield event
    167175