We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am getting different results when using Java 11 and 17. I am not sure if it is an issue with this library, or a "feature" in Java 17...
Here is the code, also available here: https://github.com/tomasbjerre/handlebars-issue
dependencies { api 'com.github.jknack:handlebars:4.3.0' testImplementation 'junit:junit:4.12' testImplementation 'org.slf4j:slf4j-simple:1.7.13' testImplementation 'org.assertj:assertj-core:2.3.0' }
The assertions at the end of the test case shows how it differs.
import java.io.StringWriter; import java.io.Writer; import org.junit.Test; import com.github.jknack.handlebars.Context; import com.github.jknack.handlebars.Handlebars; import com.github.jknack.handlebars.Template; public class TemplatesTest { public class Issue { private final boolean theVal; public Issue() { this.theVal = true; } public boolean isTheVal() { return this.theVal; } } @Test public void test() throws Exception { final Handlebars handlebars = new Handlebars(); final Template template = handlebars.compileInline("{{isTheVal}}\n" + "isTheVal: {{#isTheVal}}yes{{/isTheVal}}\n"); final Object context = new Issue(); final Context changelogContext = Context.newContext(context); final Writer writer = new StringWriter(); template.apply(changelogContext, writer); final String rendered = writer.toString(); // Java 17 // assertThat(rendered).isEqualTo("true\n" + "isTheVal: yes\n"); // Java 11 assertThat(rendered).isEqualTo("\n" + "isTheVal: \n"); } }
$ javac -version javac 17.0.1
$ java -version openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-Ubuntu-120.04) OpenJDK 64-Bit Server VM (build 17.0.1+12-Ubuntu-120.04, mixed mode, sharing)
$ javac -version javac 11.0.13
$ java -version openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
The text was updated successfully, but these errors were encountered:
The default value resolvers are different when using different JDKs. See https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/ValueResolver.java#L87
@jknack This changed seemed to cause lots of confusion. Maybe some doc needs to be added.
Sorry, something went wrong.
Fix jknack#951 templates breaking on upgrade
1138a7c
No branches or pull requests
I am getting different results when using Java 11 and 17. I am not sure if it is an issue with this library, or a "feature" in Java 17...
Here is the code, also available here:
https://github.com/tomasbjerre/handlebars-issue
The assertions at the end of the test case shows how it differs.
Java versions tested
The text was updated successfully, but these errors were encountered: