AdaptiveCards
AdaptiveCards copied to clipboard
Optional fields support
Currently, I have a structure that has optional fields defined.
If the structure does not have the field, the template library currently outputs the name of the field.
I can get around that by using the GlobalSettings like this. GlobalSettings.getUndefinedFieldValueSubstitutionString = (s) => 'OOPS';
Which will correctly substitute OOPS. However, if I replace oops with '' (the empty string), it reverts to showing the template (presumably because of not checking === undefined).
Is there a way to tell the template language not to care?
Maybe a reference like ${must.be.present.until.here?} or ${may?.be?.completely?.missing?}
As a workaround, to hide the values in a template, you can use $when on an object:
"$when": "${exists(path.to.something)}"
Or if you're in building say markdown, and condionally want nothing, use ${if(exists(path.to.something), path.to.something, '')}