skttl
(Søren Kottal)
July 11, 2025, 7:30am
1
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?
warren
(Warren Buckley)
July 11, 2025, 8:00am
2
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 }
main
← v16/feature/ufm-js-expressions
opened 01:55PM - 07 Jul 25 UTC
### Description
Adds support for JavaScript-like expressions to [UFM](https:/… /docs.umbraco.com/umbraco-cms/reference/umbraco-flavored-markdown).
Using a syntax similar to JavaScript's [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), expressions are delimited by a dollar sign and curly braces: `${expression}`.
The implementation makes use of the [Heximal Expressions](https://www.npmjs.com/package/@heximal/expressions) library ([source](https://github.com/elematic/heximal/tree/main/packages/expressions)). The syntax should feel familiar to AngularJS expressions, with piped filters/transformers.
#### How to test?
Go to a document that can make use of UFM-syntax/label-templates, e.g. a block list item or a property's description.
Try adding syntax for various scenarios, for example...
- Rendering a literal value: `${ propertyAlias }`
- Property drilling: `${ propertyAlias.length }`
- Conditionals: `${ propertyAlias.length > 0 ? "Yes" : "No" }`
- Piped filters: `${ propertyAlias | uppercase }`
1 Like
skttl
(Søren Kottal)
July 11, 2025, 8:04am
3
Ooh thats nice! Thanks for sharing!
It’s not super important for me right now, and I can definitely wait for 16.2.