LogoLogo
Back to studio
  • 🧠Core Concepts
    • Introduction to Formsort
    • Formsort quickstart guides
      • Add content and collect answers
      • Capture demographic data
      • Add informational content
      • Template your variables
      • Add conditional logic
      • Using conditional logic with Calculated and API variables
      • Add a scheduling option
      • End the flow
      • Review your variable schema
      • Set up integrations
    • How data works in Formsort
      • Responder UUIDs
    • Understanding flows
    • Versioning in Formsort (Deploying)
      • Variant revisions
      • Managing revisions
  • ✨Creating Flows
    • Building a new flow
      • Groups
      • Steps
      • Copy-pasting form content
  • Adding questions and content
    • Questions
      • Select
      • Text
      • Address
      • Comparison
      • Confirmation
      • Date
      • Date & time
      • Email address
      • File upload
      • Grid choice
      • Iframe
      • Image upload
      • Number
      • Payment
      • Phone number
      • Postal code
      • Question group
      • Region
      • Signature
      • SSN
      • Yes/No
    • Content
      • Statement
      • Image
      • Next button
      • Video
      • Divider
      • Map
  • Controlling the flow with conditions and logic
    • Advanced logic
  • Variable templating
  • Redirects and endings
  • Field validation
  • Flow and variant management
  • Content library
  • 🧬JSON Form Definition
  • JSON schemas
  • Validating flow schemas
  • Events subscriptions
  • Flow content data format
  • 🎨Styling
    • Customizing appearance
      • Content area & form layout
      • Buttons
      • Typography
      • UI states
      • Color and dimension variables
      • Question containers
      • Inputs and dropdowns
      • Checkmarks
      • Tables
      • Sliders
      • Divider lines
      • Progress bar
      • Comparison cards
      • Animations and transitions
  • CSS & Advanced Styling
    • Custom CSS overrides
    • Step styling
    • CSS reference
  • 🔁Form Behavior Settings
    • Variant settings
      • Form behavior for returning users
      • Group ranking API
    • Navigation sidebar
  • ⚙️Response Data Collection & Management
    • Schema (variables)
      • Variables from questions
      • Externally provided variables
      • Calculated variables
      • API lookups
      • System Library variables
      • Orphaned variables
  • Saving & retrieving responses
  • Importing Data
    • URL parameters
    • POST body
    • Embed query parameters
  • 📊Analytics and Attribution
    • Built-in analytics
    • Split testing
  • 🚀Publishing and Deployment
    • Live preview overview
    • Environments
      • Loading different environments
    • Embedding
      • Web-embed API
        • React-embed
      • Adding authentication
      • Embedding forms in iOS and Android
      • Setting up a dev environment
    • Pre-deployment checklist
  • 📁Workspace Management
    • Accounts
      • Roles and permissions
    • Custom domains
    • Workspace domain detection
  • 🛠️Formsort Admin API
    • Admin API
  • 🔌Integrations
    • Form answers and events
      • Analytics events
      • Signed requests
      • Event payload shape
      • Submission frequencies
      • Runtime error reporting
    • Integration reference
      • Amplitude
        • Amplitude cross domain tracking
      • BigQuery
      • FullStory
      • Google Analytics
        • Updating from Universal Analytics to GA4
      • Google Cloud Storage
      • Google Sheets
      • Google Tag Manager (GTM)
        • JavaScript triggered by flow events
      • Hubspot
      • Jornaya
      • Optimizely
      • PostgreSQL
      • Redshift
      • Rudderstack
      • S3
      • Salesforce
      • Segment
        • Segment Setup
        • Segment cross domain tracking
      • Stripe
      • TrustedForm
      • Webhooks
        • Zapier
Powered by GitBook
On this page
  • Inserting Answer Values into Content
  • Where Variable Templating Works
  • Template Formatting Functions
  • Available functions
  • Need More Customization?

Was this helpful?

Variable templating

Personalize your flows by reusing answers you've collected.

PreviousAdvanced logicNextRedirects and endings

Last updated 9 days ago

Was this helpful?

Variable templating allows you to dynamically insert answers collected from your flow into other content, such as question labels and redirects. This enables a more personalized and dynamic user experience.

Inserting Answer Values into Content

You can reference any previously collected answer by wrapping its variable name in double curly braces:

Hello, {{first_name}}!

If the user entered Susana as their first_name, the above would render as:

Hello, Susana!

This syntax is similar to templating systems like Mustache or Handlebars.

Important Behavior to Know

  • Templated variables must be defined before use. Formsort does not allow referencing variables on steps that come before the variable is collected.

  • If a variable is missing, its name will be shown as-is. For example: Hello, {{first_name}}! will render exactly like that if first_name hasn’t been defined.


Where Variable Templating Works

Templating is most commonly used in text content (like question labels), but it’s supported almost everywhere across a flow. Some examples include (but are not limited to):

Text and Question Labels

Personalize instructions and messages dynamically based on user input:

Redirect URLs

Redirect users to dynamic URLs based on their answers.

Example: Forward the user's name to the next destination:


Template Formatting Functions

Template functions let you format answer values before they are displayed, making your flow content cleaner and more user-friendly.

Using template functions

Sometimes raw answers—especially numbers—need formatting to be user-friendly. Template functions allow you to transform these values within your templates using the pipe symbol (|).

Example: You might have a variable called product_price from an API that returns a number:

Price: {{product_price}}.

If product_price = 1499.95, the result would be:

Price: 1499.95

This isn’t ideal for displaying prices. Instead, use the usd function to format the number as US dollars:

Price: {{product_price | usd}}.

This would render as:

Price: $1,499.95

Much better.

Chaining template functions

You can apply multiple formatting functions by chaining them with |.

Example:

Price: {{product_price | round | usd}}.

This first rounds the number, then formats it as currency:

Price: $1,500

Available functions

Here’s a list of supported functions you can use within templates:

Function
Description

capitalize

Capitalizes the first letter of a string.

ceil

Rounds up to the nearest integer.

default "text"

Displays fallback text if the variable is not defined. Example: Allergies: {{allergies | default "none"}}

floor

Rounds down to the nearest integer.

get "key"

Gets a nested value from an object. Example: {{user_address | get "city"}}

label

Returns the label of a selected choice (useful with multiple choice questions).

lowercase

Converts text to lowercase.

round

Rounds to the nearest whole number.

uppercase

Converts text to UPPERCASE.

usd

Formats a number as US currency. 1499.95 → $1,499.95


Need More Customization?

If none of the built-in functions meet your needs:

  • Have a feature request? Reach out via chat—we’d love to hear what would help!

Use a to pre-format your value before inserting it into templates.

calculated answer