Exemple #1
0
    def validate(cls, expression):
        if not isinstance(expression, str):
            raise exc.JinjaEvaluationException("Unsupported type '%s'." %
                                               type(expression))

        try:
            cls._env.parse(expression)
        except jinja2.exceptions.TemplateError as e:
            raise exc.JinjaGrammarException("Syntax error '%s'." % str(e))
Exemple #2
0
    def validate(cls, expression):
        LOG.debug("Validating Jinja expression [expression='%s']", expression)

        if not isinstance(expression, six.string_types):
            raise exc.JinjaEvaluationException("Unsupported type '%s'." %
                                               type(expression))

        try:
            cls._env.parse(expression)
        except jinja2.exceptions.TemplateError as e:
            raise exc.JinjaGrammarException("Syntax error '%s'." % str(e))
Exemple #3
0
    def validate(cls, expression):
        if not isinstance(expression, str):
            raise exc.JinjaEvaluationException("Unsupported type '%s'." %
                                               type(expression))

        try:
            parser = jinja_parse.Parser(cls._env, expression, state='variable')

            parser.parse_expression()
        except jinja2.exceptions.TemplateError as e:
            raise exc.JinjaGrammarException("Syntax error '%s'." % str(e))