Binding Expressions Support
Scryber uses a Handlebars-style expression syntax ({{...}}) to bind data and execute functions within templates. This chart covers all supported helpers, operators, functions, and special variables.
All binding features are Scryber-specific — standard HTML has no equivalent built-in template engine.
On this page
Expression Syntax
| Syntax |
Example |
Description |
| Output value |
{{model.name}} |
Renders a data value as text |
| Expression |
{{price * qty}} |
Evaluates an inline expression |
| Function call |
{{toUpper(model.name)}} |
Calls a built-in function |
| Conditional expression |
{{if(score >= 90, 'A', 'B')}} |
Inline ternary |
| CSS variable |
{{var(--theme-color)}} |
Reads a CSS custom property value |
| CSS calc |
{{calc(100% - 20pt)}} |
CSS calculation (prefer operators directly) |
Handlebars Helpers
Block-level helpers for control flow and iteration.
| Helper |
Syntax |
Description |
Reference |
| each |
{{#each items}}...{{/each}} |
Iterate over a collection; access current item with {{this}} |
 |
| with |
{{#with object}}...{{/with}} |
Change the data context to a specific object |
 |
| if |
{{#if condition}}...{{/if}} |
Conditional block; condition is any expression |
 |
| else if |
{{else if condition}} |
Additional branch in an if block |
 |
| else |
{{else}} |
Fallback branch when no condition is met |
 |
| log |
{{log "message"}} |
Writes a debug message to the trace log |
 |
Operators
Used within {{expression}} bindings. Operator precedence follows standard mathematical rules.
Mathematical
| Operator |
Example |
Description |
Reference |
+ |
{{a + b}} |
Addition |
→ |
- |
{{a - b}} |
Subtraction |
→ |
* |
{{a * b}} |
Multiplication |
→ |
/ |
{{a / b}} |
Division |
→ |
% |
{{a % b}} |
Modulus (remainder) |
→ |
^ |
{{a ^ b}} |
Power (exponentiation) |
→ |
Comparison
| Operator |
Example |
Description |
Reference |
== |
{{a == b}} |
Equality |
→ |
!= |
{{a != b}} |
Inequality |
→ |
< |
{{a < b}} |
Less than |
→ |
<= |
{{a <= b}} |
Less than or equal |
→ |
> |
{{a > b}} |
Greater than |
→ |
>= |
{{a >= b}} |
Greater than or equal |
→ |
Logical
| Operator |
Example |
Description |
Reference |
&& |
{{a && b}} |
Logical AND |
→ |
\|\| |
{{a \|\| b}} |
Logical OR |
→ |
! |
{{!a}} |
Logical NOT |
 |
Navigation & Null Handling
| Operator |
Example |
Description |
Reference |
. |
{{model.address.city}} |
Property access |
 |
[] |
{{items[0]}} |
Array index access |
 |
.. |
{{../parentValue}} |
Navigate to parent context |
 |
?? |
{{value ?? 'default'}} |
Null coalescing — returns right side if left is null |
→ |
this |
{{this.name}} |
Current context reference |
 |
Special Variables
Available automatically in specific contexts.
| Variable |
Context |
Description |
@index |
{{#each}} loops |
Zero-based index of the current item |
@first |
{{#each}} loops |
true if this is the first item |
@last |
{{#each}} loops |
true if this is the last item |
this |
Any |
Current data context |
. |
Any |
Shorthand for current context |
.. |
Nested contexts |
Parent context reference |
model |
Root |
Root data model (from doc.Params["model"]) |
Functions
Conversion
| Function |
Signature |
Description |
Reference |
| string |
string(value, format?) |
Convert to string with optional format |
 |
| int |
int(value) |
Convert to 32-bit integer |
 |
| long |
long(value) |
Convert to 64-bit integer |
 |
| double |
double(value) |
Convert to double-precision float |
 |
| decimal |
decimal(value) |
Convert to decimal number |
 |
| bool |
bool(value) |
Convert to boolean |
 |
| date |
date(value) |
Convert to DateTime |
 |
| typeof |
typeof(value) |
Returns the type name as a string |
 |
String
| Function |
Signature |
Description |
Reference |
| concat |
concat(s1, s2, ...) |
Concatenate strings |
 |
| join |
join(separator, array) |
Join array elements with a separator |
 |
| substring |
substring(str, start, length?) |
Extract a portion of a string |
 |
| replace |
replace(str, find, replace) |
Replace text in a string |
 |
| toLower |
toLower(str) |
Convert to lowercase |
 |
| toUpper |
toUpper(str) |
Convert to uppercase |
 |
| trim |
trim(str) |
Remove whitespace from both ends |
 |
| trimEnd |
trimEnd(str) |
Remove trailing whitespace |
 |
| length |
length(str) |
Get string length |
 |
| contains |
contains(str, search) |
Check if string contains text |
 |
| startsWith |
startsWith(str, prefix) |
Check if string starts with prefix |
 |
| endsWith |
endsWith(str, suffix) |
Check if string ends with suffix |
 |
| indexOf |
indexOf(str, search) |
Find position of a substring |
 |
| padLeft |
padLeft(str, len, char) |
Pad string on the left |
 |
| padRight |
padRight(str, len, char) |
Pad string on the right |
 |
| split |
split(str, separator) |
Split string into an array |
 |
| format |
format(value, formatStr) |
Format value using a .NET format string |
 |
| regexIsMatch |
regexIsMatch(str, pattern) |
Test if string matches a regex |
 |
| regexMatches |
regexMatches(str, pattern) |
Return all regex matches |
 |
| regexSwap |
regexSwap(str, pattern, replacement) |
Replace using a regex |
 |
Mathematical
| Function |
Signature |
Description |
Reference |
| abs |
abs(value) |
Absolute value |
 |
| ceiling |
ceiling(value) |
Round up to nearest integer |
 |
| floor |
floor(value) |
Round down to nearest integer |
 |
| round |
round(value, decimals?) |
Round to nearest value |
 |
| truncate |
truncate(value) |
Remove decimal portion |
 |
| sqrt |
sqrt(value) |
Square root |
 |
| pow |
pow(base, exponent) |
Raise to a power |
 |
| exp |
exp(value) |
e raised to a power |
 |
| log |
log(value) |
Natural logarithm |
 |
| log10 |
log10(value) |
Base-10 logarithm |
 |
| sign |
sign(value) |
Returns -1, 0, or 1 |
 |
| sin |
sin(angle) |
Sine (radians) |
 |
| cos |
cos(angle) |
Cosine (radians) |
 |
| tan |
tan(angle) |
Tangent (radians) |
 |
| asin |
asin(value) |
Arcsine |
 |
| acos |
acos(value) |
Arccosine |
 |
| atan |
atan(value) |
Arctangent |
 |
| degrees |
degrees(radians) |
Convert radians to degrees |
 |
| radians |
radians(degrees) |
Convert degrees to radians |
 |
| pi |
pi() |
π constant (3.14159…) |
 |
| e |
e() |
Euler’s number (2.71828…) |
 |
| random |
random() |
Random value between 0 and 1 |
 |
Date & Time
| Function |
Signature |
Description |
Reference |
| addDays |
addDays(date, n) |
Add days to a date |
 |
| addMonths |
addMonths(date, n) |
Add months to a date |
 |
| addYears |
addYears(date, n) |
Add years to a date |
 |
| addHours |
addHours(date, n) |
Add hours to a date |
 |
| addMinutes |
addMinutes(date, n) |
Add minutes to a date |
 |
| addSeconds |
addSeconds(date, n) |
Add seconds to a date |
 |
| addMilliseconds |
addMilliseconds(date, n) |
Add milliseconds to a date |
 |
| daysBetween |
daysBetween(d1, d2) |
Days between two dates |
 |
| hoursBetween |
hoursBetween(d1, d2) |
Hours between two dates |
 |
| minutesBetween |
minutesBetween(d1, d2) |
Minutes between two dates |
 |
| secondsBetween |
secondsBetween(d1, d2) |
Seconds between two dates |
 |
| yearOf |
yearOf(date) |
Extract the year |
 |
| monthOfYear |
monthOfYear(date) |
Extract the month (1–12) |
 |
| dayOfMonth |
dayOfMonth(date) |
Extract the day of month |
 |
| dayOfWeek |
dayOfWeek(date) |
Extract the day of week |
 |
| dayOfYear |
dayOfYear(date) |
Extract the day of year (1–365) |
 |
| hourOf |
hourOf(date) |
Extract the hour (0–23) |
 |
| minuteOf |
minuteOf(date) |
Extract the minute (0–59) |
 |
| secondOf |
secondOf(date) |
Extract the second (0–59) |
 |
| millisecondOf |
millisecondOf(date) |
Extract the millisecond (0–999) |
 |
Logical
| Function |
Signature |
Description |
Reference |
| if |
if(condition, trueVal, falseVal) |
Ternary conditional |
 |
| ifError |
ifError(expression, fallback) |
Return fallback if expression throws |
 |
| in |
in(value, a, b, ...) |
Check if value exists in a list |
 |
Collection
| Function |
Signature |
Description |
Reference |
| count |
count(array) |
Count elements |
 |
| countOf |
countOf(array) |
Alias for count() |
 |
| sum |
sum(array) |
Sum numeric values |
 |
| sumOf |
sumOf(array, 'prop') |
Sum a property across elements |
 |
| min |
min(array) |
Minimum value |
 |
| minOf |
minOf(array, 'prop') |
Minimum of a property |
 |
| max |
max(array) |
Maximum value |
 |
| maxOf |
maxOf(array, 'prop') |
Maximum of a property |
 |
| collect |
collect(expr, array) |
Map an expression over an array |
 |
| each |
each(array) |
Iterate over array (returns array) |
 |
| firstWhere |
firstWhere(array, condition) |
First matching element |
 |
| selectWhere |
selectWhere(array, condition) |
Filter array by condition |
 |
| sortBy |
sortBy(array, 'prop') |
Sort by property |
 |
| reverse |
reverse(array) |
Reverse array order |
 |
Statistical
| Function |
Signature |
Description |
Reference |
| average |
average(array) |
Mean of array values |
 |
| averageOf |
averageOf(array, 'prop') |
Mean of a property |
 |
| mean |
mean(array) |
Alias for average() |
 |
| median |
median(array) |
Middle value |
 |
| mode |
mode(array) |
Most common value |
 |
CSS / Document
| Function |
Signature |
Description |
Reference |
| calc |
calc(expression) |
CSS calculation (prefer inline operators) |
 |
| var |
var(--name) |
Read a CSS custom property value |
 |
Custom Functions & Operators
The binding system can be extended with custom functions and operators registered at startup:
// Register a custom function
BindingCalcExpressionFactory.RegisterFunction(new MyCustomFunction());
// Register a custom operator
BindingCalcExpressionFactory.RegisterOperator(new MyCustomOperator());
See the Configuration section for more on extending Scryber.
Common Patterns
Format a currency value:
Format a date:
{{format(orderDate, 'yyyy-MM-dd')}}
Conditional class:
<div class="{{if(isActive, 'active', 'inactive')}}">
Null-safe navigation:
{{user.address.city ?? 'No city'}}
Sum a collection property:
Total: {{format(sumOf(items, 'price'), 'C2')}}
Loop with index:
{{#each items}}
<p>{{@index}}. {{this.name}}</p>
{{/each}}
See Also