Field Helpers - Strings / Formatting


  • capitalizeFirst 
  • capitalizeEach 
  • center 
  • dashify 
  • hyphenate 
  • lowercase 
  • sentence 
  • titleize 
  • uppercase 
  • reverse 
  • count 
  • replace 
  • ellipsis 
  • truncate 
  • startsWith 
  • occurrences
  • triple brackets

{{capitalizeEach}}

Capitalizes each word in a string. 
Parameters: none

{{capitalizeEach "capitalize EACH word in this sentence"}}

Renders to:

Capitalize EACH Word In This Sentence

{  {{capitalizeFirst}}

Capitalizes the first word in a string. 
Parameters: none

{{capitalizeFirst "capitalize first word in this sentence"}}

Renders to:

Capitalize first word in this sentence

{{ {{center}}

Centers a string using non-breaking spaces. 
Parameters: spaces: int - The number of spaces. (Required)

{{center "Bender should not be allowed on tv." 10}}

Renders to:

|              Bender should not be allowed on tv.              |

{{ {{dashify}}

Same as hyphenate, but replaces dots in string with hyphens. 
Parameters: none

{{dashify "make.this.all.hyphenated"}}

Renders to:

make-this-all-hyphenated

{{ {{formatPhoneNumber}}

Output a formatted phone number

Credit: Treehouse Blog

Data:

number: 4444444444

Template:

{{formatPhoneNumber number}}

Renders to:

(444) 444-4444

{{ {{hyphenate}}

Replace spaces in string with hyphens. 
Parameters: none

{{hyphenate "make this all hyphenated"}}

Result:

make-this-all-hyphenated

{{ {{lowercase}}

Turns a string to lowercase. 
Parameters: none

{{lowercase "MAKE THIS ALL LOWERCASE"}}

Renders to:

make this all lowercase

{{ {{reverse}}

Reverses a string. 
Parameters: none

{{reverse "bender should NOT be allowed on TV."}}

Renders to:

.VT no dewolla eb TON dluohs redneb

{{ {{titleize}}

Capitalizes all words within a string. Taken from the templating library Walrus by Jeremy Ruppel. 
Parameters: none

{{titleize "capitalize EACH word in this sentence"}}

Renders to:

Capitalize Each Word In This Sentence.

{{ {{truncate}}

Truncates a string given a specified length, providing a custom string to denote an omission. 
Parameters:

  • length: int- The number of characters to keep (Required).
  • omission: string - A string to denote an omission (Optional).

{{truncate "Bender should not be allowed on tv." 31 "..."}}

Renders to:

Bender should not be allowed...

{{ {{uppercase}}

Turns a string to uppercase. Opposite of {{lowercase}}. 
Parameters: none

 {{uppercase "make this all uppercase"}}

Renders to:

MAKE THIS ALL UPPERCASE

{{ Triple Brackets {{{ }}}

{{{ }}} removes any formatting and html tags from paragraphs, like maintenance or property descriptions 

Parameters:

  • Add { } to a {{field}}

{{{proposal.longDescription}}}

Renders to:

Brand newly refurbished extremely large two double bedroom maisonette for rent. Situated in one of greens most premium locations, two double bedrooms, large living room, kitchen, wet room bathroom and lovely garden. Extremely clean and bright with lots of space.