Trying to be clever with UFM fallbacks

I’m trying to be clever with UFM in my block label templates.

I have a block with an image, a headline and a text.

If there is an image selected, I want to display the name if that

  • if not, it should display the headline
  • if no headline, it should display the beginning of the text.

I found the fallback filter in the source, and YOLO’ed this template
{umbContentName: image | fallback:{umbValue: headline | fallback:{umbValue: text | strip-html | truncate:36}}}

But quickly found out, you can’t nest UFM components like that.

Is there another way it can be done?

Yeh I don’t think ternary style options are possible yet
However I have just seen this PR from Lee that has got merged in…

But if you need it now/today then think the only option is to write your own UFM filter or UFM component to deal with the entire logic in that.

But if you can wait (assume due in 16.1.0) then looks like we will have some nice new options to help ease the transition from Angular expressions.

  • Rendering a literal value: ${ propertyAlias }
  • Property drilling: ${ propertyAlias.length }
  • Conditionals: ${ propertyAlias.length > 0 ? "Yes" : "No" }
  • Piped filters: ${ propertyAlias | uppercase }
1 Like

Ooh thats nice! Thanks for sharing!

It’s not super important for me right now, and I can definitely wait for 16.2.