Skip to content

Commit 199563e

Browse files
committed
UFM Expressions
1 parent 3fddf23 commit 199563e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

16/umbraco-cms/reference/umbraco-flavored-markdown.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,41 @@ The following UFM filters are available to use.
6868
| Uppercase | `uppercase` | `{umbValue: headline \| uppercase}` |
6969
| Word Limit | `word-limit` | `{umbValue: intro \| word-limit:15}` |
7070

71+
72+
## UFM Expressions (JavaScript-like syntax)
73+
74+
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.
75+
76+
### Syntax
77+
78+
Expressions are defined using the `${ ... }` syntax, (this is different to syntax outlined above). You can use standard JavaScript operators, function calls, and property access.
79+
80+
**Examples:**
81+
82+
```markdown
83+
${ propertyAlias } // Renders a literal value
84+
${ propertyAlias.length } // Property drilling
85+
${ propertyAlias.length > 0 ? "Yes" : "No" } // Conditionals
86+
${ propertyAlias | uppercase } // Piped filters, as detailed above
87+
${ propertyAlias.toUpperCase() } // Native JavaScript functions
88+
${ 1 + 2 } // Expression evaluation/calculation; renders "3"
89+
```
90+
91+
Expressions can reference property aliases, perform calculations, concatenate strings, and more.
92+
93+
### Supported operations
94+
95+
- Arithmetic (`+`, `-`, `*`, `/`)
96+
- Logical (`&&`, `||`, `!`)
97+
- Conditional (`? :`)
98+
- Function calls (limited to safe native/built-in functions like `toUpperCase()`, `toLowerCase()`, etc.)
99+
- Property access (`myProperty.length`)
100+
101+
### Sandboxed evaluation
102+
103+
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.
104+
105+
71106
## UFM components
72107

73108
### Available UFM components

0 commit comments

Comments
 (0)