From 199563e9974d35f232d1b2ae16aeda16cd305b0e Mon Sep 17 00:00:00 2001 From: leekelleher Date: Wed, 27 Aug 2025 09:45:23 +0100 Subject: [PATCH 1/5] UFM Expressions --- .../reference/umbraco-flavored-markdown.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/16/umbraco-cms/reference/umbraco-flavored-markdown.md b/16/umbraco-cms/reference/umbraco-flavored-markdown.md index 0369bd74d27..4dda1d55df7 100644 --- a/16/umbraco-cms/reference/umbraco-flavored-markdown.md +++ b/16/umbraco-cms/reference/umbraco-flavored-markdown.md @@ -68,6 +68,41 @@ The following UFM filters are available to use. | Uppercase | `uppercase` | `{umbValue: headline \| uppercase}` | | Word Limit | `word-limit` | `{umbValue: intro \| word-limit:15}` | + +## UFM Expressions (JavaScript-like syntax) + +UFM can also support JavaScript-like expressions to allow for simple logic within label templates and descriptions. This is especially useful for advanced label rendering, fallback values, and dynamic formatting without developing your own custom UFM components or filters. + +### Syntax + +Expressions are defined using the `${ ... }` syntax, (this is different to syntax outlined above). You can use standard JavaScript operators, function calls, and property access. + +**Examples:** + +```markdown +${ propertyAlias } // Renders a literal value +${ propertyAlias.length } // Property drilling +${ propertyAlias.length > 0 ? "Yes" : "No" } // Conditionals +${ propertyAlias | uppercase } // Piped filters, as detailed above +${ propertyAlias.toUpperCase() } // Native JavaScript functions +${ 1 + 2 } // Expression evaluation/calculation; renders "3" +``` + +Expressions can reference property aliases, perform calculations, concatenate strings, and more. + +### Supported operations + +- Arithmetic (`+`, `-`, `*`, `/`) +- Logical (`&&`, `||`, `!`) +- Conditional (`? :`) +- Function calls (limited to safe native/built-in functions like `toUpperCase()`, `toLowerCase()`, etc.) +- Property access (`myProperty.length`) + +### Sandboxed evaluation + +All expressions are evaluated in a sandbox. Only safe operations and methods are allowed; access to global objects, external APIs, or unsafe functions will be blocked. To extend expressions with your own functions, it is recommended to use the piped UFM Filter syntax. + + ## UFM components ### Available UFM components From 03821957ff788c85a2351cdb9e7bec19334cb59b Mon Sep 17 00:00:00 2001 From: leekelleher Date: Wed, 27 Aug 2025 09:56:48 +0100 Subject: [PATCH 2/5] Vale correction: replaced "simple logic" with "basic logic" --- 16/umbraco-cms/reference/umbraco-flavored-markdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/reference/umbraco-flavored-markdown.md b/16/umbraco-cms/reference/umbraco-flavored-markdown.md index 4dda1d55df7..9fa6d634b98 100644 --- a/16/umbraco-cms/reference/umbraco-flavored-markdown.md +++ b/16/umbraco-cms/reference/umbraco-flavored-markdown.md @@ -71,7 +71,7 @@ The following UFM filters are available to use. ## UFM Expressions (JavaScript-like syntax) -UFM can also support JavaScript-like expressions to allow for simple logic within label templates and descriptions. This is especially useful for advanced label rendering, fallback values, and dynamic formatting without developing your own custom UFM components or filters. +UFM can also support JavaScript-like expressions to allow for basic logic within label templates and descriptions. This is especially useful for advanced label rendering, fallback values, and dynamic formatting without developing your own custom UFM components or filters. ### Syntax From a760486bf16f21d182a8c950c512348ee67738dc Mon Sep 17 00:00:00 2001 From: Lee Kelleher Date: Wed, 27 Aug 2025 11:55:02 +0100 Subject: [PATCH 3/5] Update 16/umbraco-cms/reference/umbraco-flavored-markdown.md Co-authored-by: sofietoft --- 16/umbraco-cms/reference/umbraco-flavored-markdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/reference/umbraco-flavored-markdown.md b/16/umbraco-cms/reference/umbraco-flavored-markdown.md index 9fa6d634b98..579d4b1973e 100644 --- a/16/umbraco-cms/reference/umbraco-flavored-markdown.md +++ b/16/umbraco-cms/reference/umbraco-flavored-markdown.md @@ -75,7 +75,7 @@ UFM can also support JavaScript-like expressions to allow for basic logic within ### Syntax -Expressions are defined using the `${ ... }` syntax, (this is different to syntax outlined above). You can use standard JavaScript operators, function calls, and property access. +Expressions are defined using the `${ ... }` syntax. This is different to the syntax outlined above. You can use standard JavaScript operators, function calls, and property access. **Examples:** From 4669e8658bc7f7262f9acb1660de60f07472b09f Mon Sep 17 00:00:00 2001 From: Lee Kelleher Date: Wed, 27 Aug 2025 11:55:08 +0100 Subject: [PATCH 4/5] Update 16/umbraco-cms/reference/umbraco-flavored-markdown.md Co-authored-by: sofietoft --- 16/umbraco-cms/reference/umbraco-flavored-markdown.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/16/umbraco-cms/reference/umbraco-flavored-markdown.md b/16/umbraco-cms/reference/umbraco-flavored-markdown.md index 579d4b1973e..92029235f3c 100644 --- a/16/umbraco-cms/reference/umbraco-flavored-markdown.md +++ b/16/umbraco-cms/reference/umbraco-flavored-markdown.md @@ -100,8 +100,7 @@ Expressions can reference property aliases, perform calculations, concatenate st ### Sandboxed evaluation -All expressions are evaluated in a sandbox. Only safe operations and methods are allowed; access to global objects, external APIs, or unsafe functions will be blocked. To extend expressions with your own functions, it is recommended to use the piped UFM Filter syntax. - +All expressions are evaluated in a sandbox. Only safe operations and methods are allowed. Access to global objects, external APIs, or unsafe functions will be blocked. To extend expressions with your own functions, it is recommended to use the piped UFM Filter syntax. ## UFM components From f4a38240b93562924a274dab2ebfe49909649d42 Mon Sep 17 00:00:00 2001 From: sofietoft Date: Wed, 27 Aug 2025 13:52:08 +0200 Subject: [PATCH 5/5] Small change to trigger checks --- 16/umbraco-cms/reference/umbraco-flavored-markdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/reference/umbraco-flavored-markdown.md b/16/umbraco-cms/reference/umbraco-flavored-markdown.md index 92029235f3c..bfc6e8e6cac 100644 --- a/16/umbraco-cms/reference/umbraco-flavored-markdown.md +++ b/16/umbraco-cms/reference/umbraco-flavored-markdown.md @@ -37,7 +37,7 @@ The curly brackets indicate that the UFM syntax should be processed. The `umbVal With this example, the syntax `{umbValue: bodyText}` would be processed and rendered as the following markup: -```js +```javascript ```