String Helpers API reference for string manipulation template helpers type API Reference
Categories

String Helpers

String helpers provide utilities for manipulating and formatting strings in templates.

Functions

stringify

Converts a value to JSON string.

Template Syntax

{stringify objectToStringify}

Parameters

NameTypeDescription
aanyThe value to stringify

Returns

string - JSON string representation of the input.

Example

<pre>{stringify user}</pre>

concat

Concatenates all arguments.

Template Syntax

{concat firstName ' ' lastName}

Parameters

NameTypeDescription
args…anyValues to concatenate

Returns

string - Concatenated string of all arguments.

Example

<h1>Welcome, {concat user.firstName ' ' user.lastName}!</h1>

capitalize

Capitalizes the first letter of text.

Template Syntax

{capitalize textToCapitalize}

Parameters

NameTypeDescription
textstringThe text to capitalize

Returns

string - The input text with the first letter capitalized.

Example

<p>{capitalize pageTitle}</p>

titleCase

Converts text to title case.

Template Syntax

{titleCase textToTitleCase}

Parameters

NameTypeDescription
textstringThe text to convert

Returns

string - The input text converted to title case.

Example

<h2>{titleCase article.title}</h2>

tokenize

Creates a URL-friendly token from a string.

Template Syntax

{tokenize stringToTokenize}

Parameters

NameTypeDescription
stringstringThe string to tokenize

Returns

string - A URL-friendly token (e.g., “hello-world”).

Example

<div id="{tokenize sectionTitle}">
<h3>{sectionTitle}</h3>
</div>

truncate

Truncates text to a specified length with optional suffix.

Template Syntax

{truncate textToTruncate maxLength}
{truncate textToTruncate maxLength {suffix: '…', wordBoundary: false}}

Parameters

NameTypeDefaultDescription
textstringThe text to truncate
lengthnumberMaximum length of the output
optionsobjectTruncation options

Options

NameTypeDefaultDescription
suffixstring’…’Text to append when truncated
wordBoundarybooleantrueWhether to truncate at word boundaries

Returns

string - The truncated text with suffix if needed.

Example

<p class="summary">{truncate article.content 150}</p>
<p class="excerpt">{truncate description 50 {suffix: '…'}}</p>

escapeHTML

Escapes HTML special characters in a string.

Template Syntax

{escapeHTML stringToEscape}

Parameters

NameTypeDescription
stringstringThe string to escape

Returns

string - The input string with HTML special characters escaped.

Example

<div title="{escapeHTML userInput}">
{userInput}
</div>
<h3>User Bio</h3>
<p>
{#html escapeHTML bioHTML}
</p>

lowercase

Converts text to lowercase.

Template Syntax

{lowercase textToConvert}

Parameters

NameTypeDescription
textstringThe text to convert to lowercase

Returns

string - The text converted to lowercase.

Example

<p>Email: {lowercase userEmail}</p>
<p>Username: {lowercase displayName}</p>

uppercase

Converts text to uppercase.

Template Syntax

{uppercase textToConvert}

Parameters

NameTypeDescription
textstringThe text to convert to uppercase

Returns

string - The text converted to uppercase.

Example

<p>Code: {uppercase productCode}</p>
<p>Status: {uppercase currentStatus}</p>

Examples

Previous
Reactivity
Next
Reactivity