Exemplo n.º 1
0
    def parseASTFilter(self):
        tok = self.expect('tag')
        attrs = self.accept('attrs')

        self.expect(':')
        block = self.block()

        node = nodes.Filter(tok.val, block, attrs and attrs.attrs)
        node.line = self.line()
        return node
Exemplo n.º 2
0
    def parseFilter(self):
        tok = self.expect('filter')
        attrs = self.accept('attrs')
        self.lexer.pipeless = True
        block = self.parseTextBlock()
        self.lexer.pipeless = False

        node = nodes.Filter(tok.val, block, attrs and attrs.attrs)
        node.line = self.line()
        return node
Exemplo n.º 3
0
 def parse_filter(self, node, start_inline=False):
     while self.stream.current.type == 'pipe' or start_inline:
         if not start_inline:
             next(self.stream)
         token = self.stream.expect('name')
         name = token.value
         while self.stream.current.type == 'dot':
             next(self.stream)
             name += '.' + self.stream.expect('name').value
         if self.stream.current.type == 'lparen':
             args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
         else:
             args = []
             kwargs = []
             dyn_args = dyn_kwargs = None
         node = nodes.Filter(node,
                             name,
                             args,
                             kwargs,
                             dyn_args,
                             dyn_kwargs,
                             lineno=token.lineno)
         start_inline = False
     return node