Velocity is not a scripting language; it's a template engine.  It
doesn't have standalone expressions like that.  It has references and
directives, some directives handle expressions in the arguments.  Some
references handle expressions as arguments to method calls.

That said, even if you put ${var + 5} into a proper place for an
expression, then you would have problems because the ${} syntax is the
formal bounds for a reference, not an expression.  Try something like
this instead:

#set( $val = $var + 5)${val}

On Tue, Aug 16, 2011 at 10:15 AM, Alec Swan <alecs...@gmail.com> wrote:
> Hello,
>
> I am puzzled why evaluating ${var + 5} with var->1 bindings does not
> produce 6? Here is some sample code:
>
> Velocity.evaluate(new VelocityContext(Collections.singletonMap("var",
> 1)), writer, getClass().getSimpleName(), "${var + 5}")
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to