-
Notifications
You must be signed in to change notification settings - Fork 168
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
Jinjava clear file #866
Comments
This will happen if you have an interpreter with a different config on the stack (in this case, one that has JinjavaInterpreter parentInterpreter = JinjavaInterpreter.getCurrent();
if (parentInterpreter != null) {
renderConfig = parentInterpreter.getConfig();
...
}
JinjavaInterpreter interpreter = globalConfig
.getInterpreterFactory()
.newInstance(this, context, renderConfig);
JinjavaInterpreter.pushCurrent(interpreter);
try {
String result = interpreter.render(template); renderConfig will get overridden with the parent interpreter's config if there is an interpreter on the stack, rather than just the Try calling |
Now I get hostname={{host}} if the context does not have the necessary variable, how to make it throw an error if the required variable is not found in context? |
Are there more details to your setup. The render result should have a blank output and it should have an error in |
Yesterday I used JinjavaInterpeter.popCurrent(); and everything worked, but today it again clears the file, tell me what might be the problem? I understand that sounds unreasonable but I did even mvn clean, and did Invalidate Cache |
while(JinjavaInterpreter.getCurrent() != null) {
JinjavaInterpreter.popCurrent();
} Maybe doing this will help. |
Does not help. |
Can you reproduce this with a minimal Junit test that you can paste or link here? |
If there are no other options, then how to make sure that after rendering hostname={{hostname}} is not replaced with hostname= . You must, if the variable in the context is not found, leave the value as was hostname={{hostaname}} ? |
JUnit4: 4.12 file with extension .properties
|
If you want the exception to be thrown, then you'd run:
This will throw an UnknownTokenException. If you're using Are you telling me that after running the above code, |
No, after running the code above renderResult.getOutput() contains an empty value
|
How do you respond to my first block in the comments above? |
I thought you were wanting it to throw an exception?
the output would be:
|
Thank you, that solved my problem |
Hello, and how to make jinjava not fall with the error file contains only line |
No way to avoid that one. |
Please help on this issue
https://ru.stackoverflow.com/questions/1413804/jinjava-%d0%be%d1%87%d0%b8%d1%89%d0%b0%d0%b5%d1%82-%d1%84%d0%b0%d0%b9%d0%bb
The text was updated successfully, but these errors were encountered: