velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject Best way to handle optional attributes in 1.6.2
Date Sat, 13 Jun 2009 10:13:46 GMT
I'm generating HTML using a Velocity style sheet with version 1.6.2

The source contains lots of elements which are used to generate table
cell entries:

<property name="Name" required="">Description</property>

The "required" attribute is supposed to be "Yes" or "No", with a
default of "No".

The VSL currently has:

#if($items.getAttributeValue("required") != "")

This works OK provided that the "required" attribute is present,
however I would like to treat a missing attribute the same way as the
empty string.

The above code used to work in Velocity 1.5, but now I get


instead of


The following works, but seems rather messy:

#if($items.getAttributeValue("required") &&
$items.getAttributeValue("required") != "")

Is there a better way to handle optional attributes?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message