velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Best way to handle optional attributes in 1.6.2
Date Mon, 15 Jun 2009 22:19:56 GMT
Thanks for the suggestions which work fine.

There seems to have been a change in behaviour since version 1.5.1,
but I could not find it in the release notes. Can anyone confirm this?

On 14/06/2009, Nathan Bubna <nbubna@gmail.com> wrote:
> That should be:
>
>  #if( "$!items.getAttributeValue('required')" != "" )
>
>  Or just $!items.getAttributeValue('required') if you don't mind
>  showing empty strings.
>
>  Or if you really want to clean up the look:
>
>  public class AltTool {
>   public Object empty(Object val, Object alt) {
>     return (val == null || val.toString().length() == 0) ? alt : val;
>   }
>  }
>  context.put("alt", new AltTool());
>
>  $alt.empty($item.getAttributeValue('required'), 'No')
>
>
>  On Sat, Jun 13, 2009 at 5:39 AM, Jude
>  Robinson<dotcode+velocity@gmail.com> wrote:
>  >> Is there a better way to handle optional attributes?
>  >
>  > "!$items.getAttributeValue('required')" != ""
>  >
>  > ---------------------------------------------------------------------
>  > 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