Esempio n. 1
0
    def __init__(self, keyword, attributes, **kwargs):
        expressions = ['buffered', 'cached', 'args'
                       ] + [c for c in attributes if c.startswith('cache_')]

        super(BlockTag,
              self).__init__(keyword, attributes, expressions,
                             ('name', 'filter', 'decorator'), (), **kwargs)
        name = attributes.get('name')
        if name and not re.match(r'^[\w_]+$', name):
            raise errors.CompileException(
                "%block may not specify an argument signature",
                **self.exception_kwargs)
        if not name and attributes.get('args', None):
            raise errors.CompileException(
                "Only named %blocks may specify args", **self.exception_kwargs)
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)

        self.name = name
        self.decorator = attributes.get('decorator', '')
        self.filter_args = ast.ArgumentList(attributes.get('filter', ''),
                                            **self.exception_kwargs)
Esempio n. 2
0
 def __init__(self, keyword, attributes, **kwargs):
     super(TextTag, self).__init__(keyword, attributes, (), ('filter'), (),
                                   **kwargs)
     self.filter_args = ast.ArgumentList(attributes.get('filter', ''),
                                         **self.exception_kwargs)
Esempio n. 3
0
 def __init__(self, text, escapes, **kwargs):
     super(Expression, self).__init__(**kwargs)
     self.text = text
     self.escapes = escapes
     self.escapes_code = ast.ArgumentList(escapes, **self.exception_kwargs)
     self.code = ast.PythonCode(text, **self.exception_kwargs)