[Freemarker-devel] String comparisons
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
|
From: Jaime G. <jg...@re...> - 2013-01-30 21:43:38
|
In the code on ComparisonExpression:
else if(ltm instanceof TemplateScalarModel && rtm instanceof TemplateScalarModel) {
if(operation != EQUALS && operation != NOT_EQUALS) {
throw new TemplateException("Can not use operator " + opString + " on string values.", env);
}
String first = EvaluationUtil.getString((TemplateScalarModel)ltm, left, env);
String second = EvaluationUtil.getString((TemplateScalarModel)rtm, right, env);
comp = env.getCollator().compare(first, second);
}
Collator supports "less", "less than", "greater" and "greater than" semantics.
What is the caveat on not allowing anything but equals and not equals? There must be a reason.
(Having all the semantic behaviors would be a great way to deal with date comparisons when I need to convert dates to text, and back to a date.)
Thanks
Jaime
|