β‘ Template Expressions
Loopstack uses two distinct expression syntaxes for dynamic content rendering and data access throughout your automation configurations.
Expression Syntax Overview
Template Expressions ({{ }}) - Used for rendering dynamic content within text, typically in tool arguments, message content, and document templates:
transitions:
# ...
- id: next
from: signup_received
to: user_email_notified
call:
- tool: EmailTool
arguments:
subject: "Welcome {{user.name}}!" # Template expression that evaluates to a string
body: |
Hello {{user.name}},
{{#if user.isPremium}}
Thank you for being a premium member!
{{else}}
Consider upgrading to premium for more features.
{{/if}}
Best regards,
The TeamProperty Accessors (${ }) - Used for accessing variables and context data in YAML configuration values:
transitions:
# ...
- id: next
from: signup_received
to: user_email_notified
call:
- tool: DataProcessingHandler
arguments:
user_id: ${ ctx.workflow.user_id }
input_data: ${ inputData } # add Property directly, preserving data typeBoth syntaxes can access the same underlying data, but serve different purposes:
- Template expressions render dynamic text content with conditional logic and formatting (always outputs strings)
- Property accessors inject raw data values into configuration parameters while preserving the original data type (string, object, array, boolean, etc.)
Template Expressions {{ }}
Loopstack uses Handlebars for rendering Template Expressions. Template Expressions can utilize a range of different Handlebars features and helpers:
Handlebars Syntax
Simple variable
{{myData.name}}
Nested property
{{myData.profile.email}}
Array access
{{myData.items.[0]}}
Default Helpers
if
{{#if myData.isActive}}Welcome back!{{/if}}
if/else
{{#if myData.isAdmin}}Admin Panel{{else}}User Panel{{/if}}
unless
{{#unless myData.isBlocked}}Access granted{{/unless}}
each
{{#each myData.users}}<li>{{this.name}}</li>{{/each}}
each with else
{{#each myData.items}}{{this}}{{else}}No items{{/each}}
Comparison and Logic Helpers
eq
strict equality
{{#if (eq myData.role "admin")}}Admin{{/if}}
ne
strict inequality
{{#if (ne myData.status "inactive")}}active{{/if}}
looseEq
loose equality
{{#if (looseEq myData.count "5")}}Five{{/if}}
looseNe
loose inequality
{{#if (looseNe myData.value null)}}Has value{{/if}}
gt
greater than
{{#if (gt myData.age 18)}}Adult{{/if}}
gte
greater than or equal
{{#if (gte myData.score 90)}}Perfect!{{/if}}
lt
less than
{{#if (lt myData.cold 32)}}Freezing{{/if}}
lte
less than or equal
{{#if (lte myData.age 30)}}Young adult{{/if}}
and
{{#if (and myData.isActive myData.isVerified)}}Verified user{{/if}}
or
{{#if (or myData.isPremium myData.isTrial)}}Premium features{{/if}}
not
{{#if (not myData.isBlocked)}}Welcome{{/if}}
contains
{{#if (contains myData.email "@company.com")}}Employee{{/if}}
startsWith
{{#if (startsWith myData.doctor "Dr.")}}Doctor{{/if}}
endsWith
{{#if (endsWith myData.file.name ".pdf")}}PDF file{{/if}}
regexTest
{{#if (regexTest myData.phone "^\\+1")}}US number{{/if}}
regexTest with flags
{{#if (regexTest myData.email "^[A-Z]+@" "i")}}Valid email{{/if}}
in
in (array)
{{#if (in myData.role myData.validRoles)}}Valid role{{/if}}
in (object)
{{#if (in "email" myData)}}Has email{{/if}}
length
Total: {{length myData.items}}
isEmpty
{{#if (isEmpty myData.empty)}}No tags{{/if}}
typeOf
Type: {{typeOf myData.value}}
isNull
{{#if (isNull myData.deletedAt)}}Active{{/if}}
isUndefined
{{#if (isUndefined myData.tempData)}}No temp data{{/if}}
isNumber
{{#if (isNumber myData.age)}}Age: {{myData.age}}{{/if}}
isString
{{#if (isString myData.bio)}}{{myData.bio}}{{/if}}
isBoolean
{{#if (isBoolean myData.flag)}}Boolean value{{/if}}
isArray
{{#if (isArray myData.items)}}List of items{{/if}}
isObject
{{#if (isObject myData)}}User object{{/if}}
Mathematical Operations
add
Total: ${{add myData.price myData.tax myData.shipping}}
subtract
Discount: ${{subtract myData.original myData.sale}}
multiply
Tax: ${{multiply myData.price 0.08}}
divide
Average: {{divide myData.total myData.count}}
modulo
Remainder: {{modulo 17 5}}
Utility Helpers
default
Name: {{default myData.displayName myData.username}}
Date and Time
Current Date
currentDate
Today: {{currentDate}}
currentDate with format
{{currentDate "yyyy-MM-dd"}}
currentDate with time
{{currentDate "yyyy-MM-dd h:mm"}}
Date Formatting
formatDate
Created: {{formatDate myData.createdAt}}
formatDate with format
{{formatDate myData.event.date "yyyy-MM-dd"}}
Time Ago
timeAgo
Last seen: {{timeAgo myData.lastLoginAt}}
timeAgo for comments
Posted {{timeAgo myData.comment.createdAt}}
timeAgo for events
Event ended {{timeAgo myData.event.endDate}}