Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering of invalid template doesn't fail #373

Closed
przemekpastuszka opened this issue Oct 2, 2019 · 2 comments
Closed

Rendering of invalid template doesn't fail #373

przemekpastuszka opened this issue Oct 2, 2019 · 2 comments

Comments

@przemekpastuszka
Copy link

If you try to render following expression: {{ invalidTemplate }, then jinjava will successfully render it as text {{ invalidTemplate }, while it should fail as this template is invalid because of the missing } at the end.

Please note that python jinja complains about following template (which is a correct behavior)

@przemekpastuszka
Copy link
Author

Similar problem with {{ '2018-10-10 }}, which again is rendered as text while it should throw an exception

@matigro
Copy link

matigro commented Apr 27, 2020

Hi, I'm writing here, in this issue, because I've got the same problem.
I try to validate Template but it doesn't fail.

With Jinjava:

"Hello {{ name }! welcome to this page." 

(No error detected)

With Jinja:

>>> myString = "Hello {{ name }! welcome to this page."
>>> template = Template(myString)
...
jinja2.exceptions.TemplateSyntaxError: unexpected '}'
With Jinjava:
"{% if name == 'Hello' )%} IF-Block {% else %} ELSE-Block {% endif %}"

(No error detected)

With Jinja:

>>> myString = "{% if name == 'Hello' )%} IF-Block {% else %} ELSE-Block {% endif %}"
>>> template = Template(myString)
...
jinja2.exceptions.TemplateSyntaxError: unexpected ')'

I'm using

		<dependency>
			<groupId>com.hubspot.jinjava</groupId>
			<artifactId>jinjava</artifactId>
			<version>2.5.3</version>
		</dependency>

And my code is:

        JinjavaInterpreter interpreter = new Jinjava().newInterpreter();
        new TreeParser(interpreter, templateText).buildTree();

        // If there is an error, create the exception.
        for (TemplateError error : interpreter.getErrors()) {...}

I wish it would be useful.
Please, if I've got an error, let me know.

jasmith-hs added a commit that referenced this issue Jul 24, 2023
jasmith-hs added a commit that referenced this issue Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants