String Operators
When we need to work with strings, these operators will help with your markdown.
List of Operators
{{ append }}
{{ camelcase }}
{{ capitalize }}
{{ capitalizeAll }}
{{ center }}
{{ chop }}
{{ dashcase }}
{{ dotcase }}
{{ downcase }}
{{ ellipsis }}
{{ hyphenate }}
{{ isString }}
{{ lowercase }}
{{ occurrences }}
{{ pascalcase }}
{{ pathcase }}
{{ plusify }}
{{ prepend }}
{{ raw }}
{{ remove }}
{{ removeFirst }}
{{ replace }}
{{ replaceFirst }}
{{ reverse }}
{{ sentence }}
{{ snakecase }}
{{ split }}
{{ startsWith }}
{{ titleize }}
{{ trim }}
{{ trimLeft }}
{{ trimRight }}
{{ truncate }}
{{ truncateWords }}
{{ upcase }}
{{ uppercase }}
{{ append }}
Append the specified suffix
to the given string.
Params
str
suffix
returns
Example
{{ camelcase }}
camelCase the characters in the given string
.
Params
string
: The string to camelcase.returns
Example
{{ capitalize }}
Capitalize the first word in a sentence.
Params
str
returns
Example
{{ capitalizeAll }}
Capitalize all words in a string.
Params
str
returns
Example
{{ center }}
Center a string using non-breaking spaces
Params
str
spaces
returns
{{ chop }}
Like trim, but removes both extraneous whitespace and non-word characters from the beginning and end of a string.
Params
string
: The string to chop.returns
Example
{{ dashcase }}
dash-case the characters in string
. Replaces non-word characters and periods with hyphens.
Params
string
returns
Example
{{ dotcase }}
dot.case the characters in string
.
Params
string
returns
Example
{{ downcase }}
Lowercase all of the characters in the given string. Alias for lowercase.
Params
string
returns
Example
{{ ellipsis }}
Truncates a string to the specified length
, and appends it with an elipsis, …
.
Params
str
length
: The desired length of the returned string.returns
: The truncated string.
Example
{{ hyphenate }}
Replace spaces in a string with hyphens.
Params
str
returns
Example
{{ isString }}
Return true if value
is a string.
Params
value
returns
Example
{{ lowercase }}
Lowercase all characters in the given string.
Params
str
returns
Example
{{ occurrences }}
Return the number of occurrences of substring
within the given string
.
Params
str
substring
returns
: Number of occurrences
Example
{{ pascalcase }}
PascalCase the characters in string
.
Params
string
returns
Example
{{ pathcase }}
path/case the characters in string
.
Params
string
returns
Example
{{ plusify }}
Replace spaces in the given string with pluses.
Params
str
: The input stringreturns
: Input string with spaces replaced by plus signs
Example
{{ prepend }}
Prepends the given string
with the specified prefix
.
Params
str
prefix
returns
Example
{{ raw }}
Render a block without processing mustache templates inside the block.
Params
options
returns
Example
{{ remove }}
Remove all occurrences of substring
from the given str
.
Params
str
substring
returns
Example
{{ removeFirst }}
Remove the first occurrence of substring
from the given str
.
Params
str
substring
returns
Example
{{ replace }}
Replace all occurrences of substring a
with substring b
.
Params
str
a
b
returns
Example
{{ replaceFirst }}
Replace the first occurrence of substring a
with substring b
.
Params
str
a
b
returns
Example
{{ reverse }}
Reverse a string.
Params
str
returns
Example
{{ sentence }}
Sentence case the given string
Params
str
returns
Example
{{ snakecase }}
snake_case the characters in the given string
.
Params
string
returns
Example
{{ split }}
Split string
by the given character
.
Params
string
: The string to split.returns
character
: Default is an empty string.
Example
{{ startsWith }}
Tests whether a string begins with the given prefix.
Params
prefix
testString
options
returns
Example
{{ titleize }}
Title case the given string.
Params
str
returns
Example
{{ trim }}
Removes extraneous whitespace from the beginning and end of a string.
Params
string
: The string to trim.returns
Example
{{ trimLeft }}
Removes extraneous whitespace from the beginning of a string.
Params
string
: The string to trim.returns
Example
{{ trimRight }}
Removes extraneous whitespace from the end of a string.
Params
string
: The string to trim.returns
Example
{{ truncate }}
Truncate a string to the specified length
. Also see ellipsis.
Params
str
limit
: The desired length of the returned string.suffix
: Optionally supply a string to use as a suffix to denote when the string has been truncated. Otherwise an ellipsis (…
) will be used.returns
: The truncated string.
Example
{{ truncateWords }}
Truncate a string to have the specified number of words. Also see truncate.
Params
str
limit
: The desired length of the returned string.suffix
: Optionally supply a string to use as a suffix to denote when the string has been truncated.returns
: The truncated string.
Example
{{ upcase }}
Uppercase all of the characters in the given string. Alias for uppercase.
Params
string
returns
Example
{{ uppercase }}
Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.
Params
str
: The string to uppercaseoptions
: Handlebars options objectreturns
Example