velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alec Swan <alecs...@gmail.com>
Subject Re: Evaluating basic expression
Date Tue, 16 Aug 2011 21:11:06 GMT
This makes complete sense and it worked!

Thanks,

Alec

On Tue, Aug 16, 2011 at 2:05 PM, Nathan Bubna <nbubna@gmail.com> wrote:
> 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 <alecswan@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-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Mime
View raw message