Python jinja2.nodes.Keyword() Examples

The following are 30 code examples of jinja2.nodes.Keyword(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module jinja2.nodes , or try the search function .
Example #1
Source File: ext.py    From Flask-P2P with MIT License 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #2
Source File: ext.py    From jbox with MIT License 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #3
Source File: parser.py    From recruit with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #4
Source File: parser.py    From OpenXR-SDK-Source with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #5
Source File: jinja2ext.py    From django-cachalot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def parse(self, parser):
        tag = parser.stream.current.value
        lineno = next(parser.stream).lineno
        args, kwargs = self.parse_args(parser)
        default_cache_key = (None if parser.filename is None
                             else '%s:%d' % (parser.filename, lineno))
        kwargs.append(Keyword('default_cache_key', Const(default_cache_key),
                              lineno=lineno))
        body = parser.parse_statements(['name:end' + tag], drop_needle=True)

        return CallBlock(self.call_method('cache', args, kwargs),
                         [], [], body).set_lineno(lineno) 
Example #6
Source File: parser.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #7
Source File: jinja2ext.py    From django-cachalot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def parse_args(self, parser):
        args = []
        kwargs = []

        stream = parser.stream

        while stream.current.type != 'block_end':
            if stream.current.type == 'name' \
                    and stream.look().type == 'assign':
                key = stream.current.value
                if key not in self.allowed_kwargs:
                    parser.fail(
                        "'%s' is not a valid keyword argument "
                        "for {%% cache %%}" % key,
                        stream.current.lineno)
                stream.skip(2)
                value = parser.parse_expression()
                kwargs.append(Keyword(key, value, lineno=value.lineno))
            else:
                args.append(parser.parse_expression())

            if stream.current.type == 'block_end':
                break

            parser.stream.expect('comma')

        return args, kwargs 
Example #8
Source File: parser.py    From RSSNewsGAE with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #9
Source File: parser.py    From recruit with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #10
Source File: parser.py    From pySINDy with MIT License 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #11
Source File: parser.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #12
Source File: parser.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #13
Source File: parser.py    From scylla with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #14
Source File: parser.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #15
Source File: ext.py    From Financial-Portfolio-Flask with MIT License 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #16
Source File: parser.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #17
Source File: parser.py    From planespotter with MIT License 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #18
Source File: ext.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #19
Source File: ext.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #20
Source File: ext.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #21
Source File: ext.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #22
Source File: ext.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #23
Source File: factory.py    From snaql with MIT License 5 votes vote down vote up
def parse(self, parser):
        lineno = next(parser.stream).lineno
        expr = parser.parse_expression()
        args = [expr]
        kwargs = [nodes.Keyword('func', expr)]
        if parser.stream.skip_if('comma'):
            # Optional 'note' for function docstring
            if (
                parser.stream.current.type == 'name' and
                parser.stream.current.value in (
                    'note', 'cond_for', 'depends_on'
                )
            ):
                stream_type = parser.stream.current.value
                next(parser.stream)
                parser.stream.expect('assign')
                # Depends meta is always a list
                if stream_type == 'depends_on':
                    c_expr = parser.parse_list()
                else:
                    c_expr = parser.parse_expression()
                args.append(c_expr)
                kwargs.append(nodes.Keyword(stream_type, c_expr))

        body = parser.parse_statements(
            ['name:endsql', 'name:endquery'], drop_needle=True
        )
        raw_template = self.environment.sql_params['raws'][parser.name]

        # Lines range of original raw template
        raw_lines = slice(lineno, parser.stream.current.lineno-1)
        self.environment.sql_params.setdefault('funcs', {}).update({
            expr.value: {'raw_sql': '\n '.join(raw_template[raw_lines])}
        })
        call_node = nodes.Call(
            self.attr('_sql_process', lineno=lineno),
            args, kwargs, None, None
        )
        return nodes.CallBlock(call_node, [], [], body) 
Example #24
Source File: parser.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #25
Source File: ext.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #26
Source File: parser.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #27
Source File: ext.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #28
Source File: parser.py    From EDCOP with Apache License 2.0 5 votes vote down vote up
def parse_autoescape(self):
        node = nodes.ScopedEvalContextModifier(lineno=next(self.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', self.parse_expression())
        ]
        node.body = self.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #29
Source File: ext.py    From data with GNU General Public License v3.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node]) 
Example #30
Source File: ext.py    From data with GNU General Public License v3.0 5 votes vote down vote up
def parse(self, parser):
        node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
        node.options = [
            nodes.Keyword('autoescape', parser.parse_expression())
        ]
        node.body = parser.parse_statements(('name:endautoescape',),
                                            drop_needle=True)
        return nodes.Scope([node])