code: public static ExprBoolean toExprBoolean(Expression expr) {
  	if (expr instanceof ExprBoolean) return (ExprBoolean) expr;
  	if (expr instanceof Literal) {
  	    Boolean bool = ((Literal) expr).getBoolean(null);
  	    if (bool != null) return expr.getFactory().createLitBoolean(bool.booleanValue(), expr.getStart(), expr.getEnd());
  	    // TODO throw new TemplateException("can't cast value to a boolean value");
  	}
  	return new CastBoolean(expr);
      }
docs: Create a String expression from a Expression
  
  @param expr
  @return String expression
  @throws TemplateException