Exemplo n.º 1
0
    def parseBlock(self, text, taglist, start, tagreg, name):
        cur = start
        n = DTParser.Node()
        t = taglist[cur]

        while cur < (len(taglist) - 1):
            #basically, ignore tokens until we see <:/comment:>
            cur = cur + 1
            curtagl = taglist[cur]
            if type(curtagl) == types.StringType:
                pass
            else:
                if curtagl.tagname == self.tagname and curtagl.isclose:
                    n.add(curtagl)
                    return n, cur
                else:
                    pass
        raise DTExcept.DTCompileError(
            t, 'unexpected EOF encountered '
            'parsing <:%s:> block' % self.tagname)
Exemplo n.º 2
0
    def parseBlock(self, text, taglist, start, tagreg, name):
        """
        should return node, last.  This is only called for
        non-empty tags
        """
        cur = start
        #create a new node
        n = DTParser.Node()
        #get current tag
        t = taglist[cur]
        #this is in case they started a block with the close tag (for whatever
        #reason)
        if t.isclose:
            raise DTExcept.DTCompileError(t, 'close tag out of context')

        #add current tag to the node
        n.add(t)
        #while we haven't eaten the taglist
        while cur < (len(taglist) - 1):
            cur = cur + 1
            curtag = taglist[cur]
            if type(curtag) == types.StringType:
                n.add(curtag)
            else:
                #if it's our close tag, add it and return
                if curtag.tagname == self.tagname and curtag.isclose:
                    n.add(curtag)
                    return n, cur

                #else it's not our tag so we pass it to the generic handler
                nodeortag, last = DTParser.genHandler(text, taglist, cur,
                                                      tagreg, name)
                n.add(nodeortag)
                cur = last

        raise DTExcept.DTCompileError(
            t, 'unexpected EOF encountered '
            'parsing <:%s:> block' % self.tagname)