예제 #1
0
    def parse(self, parser):
        """Parse the {% error %} tag, returning an AST node."""
        tag = next(parser.stream)
        message = parser.parse_expression()

        node = CallBlock(
            self.call_method('_exec_error',
                             [message, Const(tag.lineno)]), [], [], [])
        node.set_lineno(tag.lineno)
        return node
예제 #2
0
    def parse(self, parser):
        tag = parser.stream.current.value
        parser.stream.next()

        subtags = self._parse_subtags(tag, parser)
        methodname = 'tag_' + tag
        if subtags:
            methodname += '_' + '_'.join(subtags)

        lineno = parser.stream.current.lineno
        content = parser.parse_statements(
          ['name:end' + tag], drop_needle=True)
        node = CallBlock(self.call_method(methodname), [], [], content)
        node.set_lineno(lineno)
        return node