Skip to content

append

The append filter is designed to concatenate a specified string to the end of the input string.

Functionality

  • Strings: Takes a string as input.
  • Appendage: Requires a string argument to append to the end.
  • Output: Returns a new string with the appended string added to the end.

Syntax

    {{ input_string | append: string_to_append }}

Arguments

  • string_to_append: The string that you want to add to the end of the input_string.

Code Samples

Example 1: Appending a Word

    {% assign greeting = "Hello" %}
   {{ greeting | append: ", world!" }}

Output:

Hello, world!
Example 2: Appending a Sentence

    {% assign message = "This is the beginning" %}
    {{ message | append: " and this is the end." }}

Output:

This is the beginning and this is the end.
Example 3: Appending a Number (Automatically Converted to String)

    {% assign count = 5 %}
   {{ "There are " | append: count | append: " items in the list." }}

Output:

There are 5 items in the list.

Outliers and Special Cases

  • Empty Strings: Appending to an empty string simply returns the appended string.
  • Non-String Input: If the input is not a string, the append filter might attempt to convert it to a string or return an error, depending on how Experience Builder handles type conversions.
  • Multiple Appends: You can chain multiple append filters to concatenate several strings together.

Key Points

  • The append filter is straightforward and useful for building strings dynamically within templates.
  • It automatically handles concatenating strings and other data types (which are converted to strings).
  • Consider using the prepend filter if you need to add a string to the beginning instead of the end.