Working with Strings

NAV IS OUTPUT

There are a number of built-in Helpers available to allow you to modify and manipulate strings.

Here are some examples of them in action:

In each of the examples below, we'll be modifying the following string:

this is my title and the length of this title is pretty long. overall it's exactly 200 characters long. And that is too long for a title. I am sneaking in a <strong>bold</strong> word at the end here.

abbreviate: Truncates a string if it is longer than the specified number of characters.

Truncating to 50 chars. An ellipsis (…) is appended to the string automatically.

abbreviated

{{abbreviate (publish element="Title") 50}}

this is my title and the length of this title i...

capitalize: Capitalizes all the whitespace separated words in a String.

capitalized

{{capitalize (publish element="Title")}}

This Is My Title And The Length Of This Title Is Pretty Long. Overall It's Exactly 200 Characters Long. And That Is Too Long For A Title. I Am Sneaking In A <strong>bold</strong> Word At The End Here.

capitalizeFirst: Capitalizes the first character of the value.

capitalizeFirst

{{capitalizeFirst (publish element="Title")}}

This is my title and the length of this title is pretty long. overall it's exactly 200 characters long. And that is too long for a title. I am sneaking in a <strong>bold</strong> word at the end here.

replace: Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

replace

{{replace (publish element="Title") "sneaking" "adding"}}

this is my title and the length of this title is pretty long. overall it's exactly 200 characters long. And that is too long for a title. I am adding in a <strong>bold</strong> word at the end here.

slugify: Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace.

slugify

{{slugify (publish element="Title")}}

this-is-my-title-and-the-length-of-this-title-is-pretty-long-overall-its-exactly--characters-long-and-that-is-too-long-for-a-title-i-am-sneaking-in-a-strongboldstrong-word-at-the-end-here

cut: Removes all values of arg from the given string.

Removing all space characters like

cut

{{cut (publish element="Title") " "}}

thisismytitleandthelengthofthistitleisprettylong.overallit'sexactly200characterslong.Andthatistoolongforatitle.Iamsneakingina<strong>bold</strong>wordattheendhere.

stripTags: Strips all [X]HTML tags.

stripTags

{{stripTags (publish element="Title")}}

this is my title and the length of this title is pretty long. overall it's exactly 200 characters long. And that is too long for a title. I am sneaking in a bold word at the end here.

upper: Converts a string into all uppercase.

upper

{{upper (publish element="Title")}}

THIS IS MY TITLE AND THE LENGTH OF THIS TITLE IS PRETTY LONG. OVERALL IT'S EXACTLY 200 CHARACTERS LONG. AND THAT IS TOO LONG FOR A TITLE. I AM SNEAKING IN A <STRONG>BOLD</STRONG> WORD AT THE END HERE.

lower: Converts a string into all lowercase.

lower

{{lower (publish element="Title")}}

this is my title and the length of this title is pretty long. overall it's exactly 200 characters long. and that is too long for a title. i am sneaking in a <strong>bold</strong> word at the end here.