title

Description

Converts a string to titlecase (first letter of each word capitalized).

 string title( string input )

Converts a string to “title case”, by capitalizing the first character of every word in the string. Other letters are left untouched, so if you want to force the other characters to be lowercase, call lower() first.

Example

 {title('auto industry')} = Auto Industry

Capitalize the First Letter of Users Names in Templates

Use Case: If you’re unable to validate or send over friendly-formatted names (such as first name), title() allows you to ensure the user’s name is always capitalized. For instance, a firstName var with the value of “john” will become “John”. (Note: Because title() only converts the first letter of the string to a capital letter, other letters in the name may remain in caps. To prevent this, see example “


Zephyr:

"Hi, {title(firstName)}! Here are today's top stories..."

Output:

"Hi, John! Here are today's top stories..."

Explanation: This script uses the title() function to find the first element of a given string value, in this instance, the “first_name” custom field (var), and capitalizes the value.


Display a User’s Name in a Template in Title Case

Use Case: You pass a variable called “first_name”, in which users can capitalize the letters however the like. For consistency, you want the first letter of everyone’s name to be capitalized with the remaining letters to be lowercase.

Zephyr:

On the profile: <p>Hello, {title(lower(first_name))}</p>

Output: Hello, Steve.

Explanation: This script uses the lower() fuction to force lowercase every element of a string, in this instance, the each letter of the “first_name” custom field on a user profile. Additionally, since the order of operations is inside to outside, after the each letter has been lowercased, the title() function capitalizes the first letter of the value.


Contact us

Top