A very common pattern is to show something else if a given variable is empty/blank/null.
Borrowing from the Oracle nvl
function, here's a very simple ColdFusion implementation of nvl. (we just kept the existing name nvl from Oracle because most of the developers were already familiar with it)
It keeps code cleaner and avoids confusing Elvis operators in an already busy view.
string function nvl(required string value1, required string value2) {
if (trim(arguments.value1) NEQ "") {
return arguments.value1;
}
return arguments.value2;
}
This is included in our common_utils
module available in all 5.5 or newer apps (older apps can find it in the common_utls.cfm
file).
<div>
The value is : #nvl(variable1, '--- Not Set ---')#
</div>