Hi,
I used a macro for this purpose:
#macro( call $foo )#if($foo)#**##end#end
...
#call( $list.add("a").add("b") )
...
I believe the #if is minimally more economic than a #set, and for sure does not
pollute the context namespace. Also the #**# was for a small bug in 1.4, where
the if-block failed parse if it was empty.
Regards
Christoph
bluejoe wrote:
> Hi, all.
>
> How to call a method without printing its return value? For example, I
> define a class MyList, which has a method:
>
> public MyList add(String e);
>
> In my template, when I write:
>
> $list.add("a").add("b")...
>
> When rendered, the method will be called, but the value returned will be
> also printed unexpectedly. To hide the output, now I have to write codes as
> below:
>
> #set($___TEMP___ = $list.add("a").add("b"))
>
> It solves my problem, but I want to know if there is any better way?
>
> -bluejoe
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]