Skip to Content
DocsConfiguration⚑ Template Expressions

⚑ 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:

tools: - name: email_sender_tool execute: - handler: EmailHandler arguments: subject: "Welcome {{user.name}}!" # Template expression 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 Team

Property Accessors (${ }) - Used for accessing variables and context data in YAML configuration values:

tools: - name: data_processor_tool execute: - handler: DataProcessingHandler arguments: input_data: ${ EXTRACTED_DATA } # Property accessor user_id: ${ context.variables.USER_ID } # Context access processing_mode: ${ options.mode } # Template options api_endpoint: ${ context.custom.apiUrl } # Custom context

Both 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.)

Loopstack uses Handlebars for rendering dynamic content. This is a comprehensive guide to available Handlebars syntax and helpers for template rendering.

Template Expressions {{ }}

Template expressions can utilize a range of different Handlebars features and helpers:

Handlebars Syntax

Simple variable

{{TEST_OBJECT.name}}

Nested property

{{TEST_OBJECT.profile.email}}

Array access

{{TEST_OBJECT.items.[0]}}

Default Helpers

if

{{#if TEST_OBJECT.isActive}}Welcome back!{{/if}}

if/else

{{#if TEST_OBJECT.isAdmin}}Admin Panel{{else}}User Panel{{/if}}

unless

{{#unless TEST_OBJECT.isBlocked}}Access granted{{/unless}}

each

{{#each TEST_OBJECT.users}}<li>{{this.name}}</li>{{/each}}

each with else

{{#each TEST_OBJECT.items}}{{this}}{{else}}No items{{/each}}


Comparison and Logic Helpers

eq

strict equality

{{#if (eq TEST_OBJECT.role "admin")}}Admin{{/if}}

ne

strict inequality

{{#if (ne TEST_OBJECT.status "inactive")}}active{{/if}}

looseEq

loose equality

{{#if (looseEq TEST_OBJECT.count "5")}}Five{{/if}}

looseNe

loose inequality

{{#if (looseNe TEST_OBJECT.value null)}}Has value{{/if}}

gt

greater than

{{#if (gt TEST_OBJECT.age 18)}}Adult{{/if}}

gte

greater than or equal

{{#if (gte TEST_OBJECT.score 90)}}Perfect!{{/if}}

lt

less than

{{#if (lt TEST_OBJECT.cold 32)}}Freezing{{/if}}

lte

less than or equal

{{#if (lte TEST_OBJECT.age 30)}}Young adult{{/if}}

and

{{#if (and TEST_OBJECT.isActive TEST_OBJECT.isVerified)}}Verified user{{/if}}

or

{{#if (or TEST_OBJECT.isPremium TEST_OBJECT.isTrial)}}Premium features{{/if}}

not

{{#if (not TEST_OBJECT.isBlocked)}}Welcome{{/if}}

contains

{{#if (contains TEST_OBJECT.email "@company.com")}}Employee{{/if}}

startsWith

{{#if (startsWith TEST_OBJECT.doctor "Dr.")}}Doctor{{/if}}

endsWith

{{#if (endsWith TEST_OBJECT.file.name ".pdf")}}PDF file{{/if}}

regexTest

{{#if (regexTest TEST_OBJECT.phone "^\\+1")}}US number{{/if}}

regexTest with flags {{#if (regexTest TEST_OBJECT.email "^[A-Z]+@" "i")}}Valid email{{/if}}

in

in (array)

{{#if (in TEST_OBJECT.role TEST_OBJECT.validRoles)}}Valid role{{/if}}

in (object) {{#if (in "email" TEST_OBJECT)}}Has email{{/if}}

length

Total: {{length TEST_OBJECT.items}}

isEmpty

{{#if (isEmpty TEST_OBJECT.empty)}}No tags{{/if}}

typeOf

Type: {{typeOf TEST_OBJECT.value}}

isNull

{{#if (isNull TEST_OBJECT.deletedAt)}}Active{{/if}}

isUndefined

{{#if (isUndefined TEST_OBJECT.tempData)}}No temp data{{/if}}

isNumber

{{#if (isNumber TEST_OBJECT.age)}}Age: {{TEST_OBJECT.age}}{{/if}}

isString

{{#if (isString TEST_OBJECT.bio)}}{{TEST_OBJECT.bio}}{{/if}}

isBoolean

{{#if (isBoolean TEST_OBJECT.flag)}}Boolean value{{/if}}

isArray

{{#if (isArray TEST_OBJECT.items)}}List of items{{/if}}

isObject

{{#if (isObject TEST_OBJECT)}}User object{{/if}}

Mathematical Operations

add

Total: ${{add TEST_OBJECT.price TEST_OBJECT.tax TEST_OBJECT.shipping}}

subtract

Discount: ${{subtract TEST_OBJECT.original TEST_OBJECT.sale}}

multiply

Tax: ${{multiply TEST_OBJECT.price 0.08}}

divide

Average: {{divide TEST_OBJECT.total TEST_OBJECT.count}}

modulo

Remainder: {{modulo 17 5}}

Utility Helpers

default

Name: {{default TEST_OBJECT.displayName TEST_OBJECT.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 TEST_OBJECT.createdAt}}

formatDate with format {{formatDate TEST_OBJECT.event.date "yyyy-MM-dd"}}

Time Ago

timeAgo

Last seen: {{timeAgo TEST_OBJECT.lastLoginAt}}

timeAgo for comments Posted {{timeAgo TEST_OBJECT.comment.createdAt}}

timeAgo for events Event ended {{timeAgo TEST_OBJECT.event.endDate}}


Last updated on