Stringtemplate compare strings not working

Can someone explain why this is not working?

StringTemplate query = new StringTemplate("hello " + "$if(param==\"val1\")$" + " it works! " + "$endif$ " + "world"); query.setAttribute("param", "val1"); System.out.println("result: "+query.toString()); 

He throws

Tree parsing error eval: 0: 0: unexpected end of subtree on org.antlr.stringtemplate.language.ActionEvaluator.ifCondition (ActionEvaluator.java:815) on org.antlr.stringtemplate.language.ConditionalExpr.write (ConditionalExpr.java:99)

+4
source share
2 answers

ST does not allow calculation in templates. That would make him part of the model.

+10
source
 StringTemplate query = new StringTemplate("hello " + "$if(paramEquals)$" + " it works! " + "$endif$ " + "world"); query.setAttribute("paramEquals", param.equals("val1")); System.out.println("result: "+query.toString()); 
+2
source

All Articles