Skip to content

This addon provides string helpers for Ember templates and components.

License

Notifications You must be signed in to change notification settings

robert-allan-frank/ember-string-fns

Repository files navigation

ember-string-fns npm version Build Status codecov

This addon provides string helpers for Ember templates and components.

To install:

ember install ember-string-fns

Usage

string-char-at

Get a character from a string at an index. See String.charAt() for details on the String.charAt function.

{{string-char-at 'ember' 2}}
{{string-char-at value index}}

string-char-code-at

Get a character by utf-16 code. See String.charCodeAt() for details on the String.charCodeAt function.

{{string-char-code-at '½' 0}}
{{string-char-code-at character index}}

string-code-point-at

Get a code by code point. See String.codePointAt() for details on the String.codePointAt function.

{{string-code-point-at '' 0}}}
{{string-code-point-at character index}}

string-concat

Concatenate a series of strings. See String.concat() for details on the String.concat function.

{{string-concat 'i' ' ' 'love' ' ' 'ember'}}
{{string-concat firstName ' ' middleInitial ' ' lastName}}

string-ends-with

Returns true if a string ends with another string. See String.endsWith() for details on the String.endsWith function.

{{string-ends-with 'i love ember' 'ember'}}
{{string-ends-with haystack needle}}

string-equals

Determines if a string equals another string.

{{string-equals 'ember' 'react'}}
{{string-equals 'ember' 'react' 'vue'}}
{{string-equals value1 value2}}
{{string-equals value1 value2 value3}}

string-from-char-code

Get a character from utf-16 codes. See String.fromCharCode() for details on the String.fromCharCode function.

{{string-from-char-code 189}}
{{string-from-char-code charCode}}

string-from-code-point

Get a character from code points. See String.fromCodePoint() for details on the String.fromCodePoint function.

{{string-from-code-point 9733}}
{{string-from-code-point codePoint}}

string-html-safe

Output an HTML safe string. See htmlSafe() for details on the htmlSafe function.

{{string-html-safe '<b>bold text</b>'}}
{{string-html-safe htmlText}}

string-includes

Returns true if a string includes another string. See String.includes() for details on the String.includes function.

{{string-includes 'i love ember framework' 'ember'}}
{{string-includes haystack needle}}

string-index-of

Returns the first occurrence index where the substring begins. See String.indexOf() for details on the String.indexOf function.

{{string-index-of 'i love ember' 'ember'}}
{{string-index-of haystack needle}}

string-last-index-of

Returns the last occurrence index where the substring begins. See String.lastIndexOf() for details on the String.lastIndexOf function.

{{string-last-index-of 'i love love ember'}}
{{string-last-index-of haystack needle}}

string-not-equals

Determines if a string does not equal another string.

{{string-not-equals 'ember' 'react'}}
{{string-not-equals value1 value2}}

string-pad-end

Returns true if a string ends with another string. See String.padEnd() for details on the String.padEnd function.

{{string-pad-end 'ember' '.' 8}}
{{string-pad-end string endPadWith totalCharacterCount}}

string-pad-start

Returns true if a string ends with another string. See String.padStart() for details on the String.padStart function.

{{string-pad-start 'ember' '.' 8}}
{{string-pad-start string frontPadWith totalCharacterCount}}

string-repeat

Repeat a string a number of times. See String.repeat() for details on the String.repeat function.

{{string-repeat 'ember' 3}}
{{string-repeat string 3}}

string-replace

Replace first occurence of a string with another string.

{{string-replace 'i love react' 'react' 'ember'}}
{{string-replace hackstack needle thimble}}

string-replace-all

Replace all occurences of a string with another string.

{{string-replace-all 'i love react, react programming' 'react' 'ember'}}
{{string-replace-all hackstack needle thimble}}

string-slice

Extract a slice from a string. See String.slice() for details on the String.slice function.

{{string-slice 'i love ember' 7}}
{{string-slice 'i love ember' 7 12}}
{{string-slice string beginIndex}}
{{string-slice string beginIndex endIndex}}

string-split

Split a string into a string[] by a delimiter. See String.split() for details on the String.split function.

{{string-split 'a.b.c' '.'}}
{{string-split string delimiter}}

string-starts-with

Returns true if a string starts with another string. See String.startsWith() for details on the String.startsWith function.

{{string-starts-with 'ember i love' 'ember'}}
{{string-starts-with haystack needle}}

string-substring

Extract a substring from a string. See String.substring() for details on the String.substring function.

{{string-substring 'i love ember' 7}}
{{string-substring 'i love ember' 7 12}}
{{string-substring string beginIndex}}
{{string-substring string beginIndex endIndex}}

string-to-camel-case

Convert a string to camel case (camelCase). See Camel Case for details.

{{string-to-camel-case 'camel case'}}
{{string-to-camel-case variableName}}

string-to-kebab-case

Convert a string to kebab case (kebab-case). See Kebab Case for details.

{{string-to-kebab-case 'kebab case'}}
{{string-to-kebab-case variableName}}

string-to-lower-case

Convert a string to lower case. See String.toLowerCase() for details on the String.toLowerCase function.

{{string-to-lower-case 'robert'}}
{{string-to-lower-case firstName}}

string-to-pascal-case

Convert a string to pascal case (PascalCase). See Pascal Case for details.

{{string-to-pascal-case 'pascal case'}}
{{string-to-pascal-case variableName}}

string-to-sentence-case

Convert a string to sentence case (Sentence case.). See Sentence Case for details. Note, sentences are considered a group of words that are completed with a !, ?, or .

{{string-to-sentence-case 'i love ember!'}}
{{string-to-sentence-case sentence}}

string-to-snake-case

Convert a string to snake case (snake_case). See Snake Case for details.

{{string-to-snake-case 'snake case'}}
{{string-to-snake-case variableName}}

string-to-title-case

Convert a string to title case (Title Case). See Title Case for details. Note, due to the subjectivity of subsets, all words are operated against.

{{string-to-title-case 'pulp fiction'}}
{{string-to-title-case movieTitle}}

string-to-upper-case

Convert a string to upper case. See String.toUpperCase() for details on the String.toUpperCase function.

{{string-to-upper-case 'frank'}}
{{string-to-upper-case lastName}}

string-trim

Trim the start and end of a string. See String.trim() for details on the String.trim function.

{{string-trim '   ember   '}}
{{string-trim string}}

string-trim-end

Trim the end of a string. See String.endsWith() for details on the String.endsWith function.

{{string-trim-end 'ember   '}}
{{string-trim-end string}}

string-trim-start

Trim the start of a string. See String.trimStart() for details on the String.trimStart function.

{{string-trim-start '   ember'}}
{{string-trim-start string}}

Related Addons

Compatibility

  • Ember.js v3.4 or above
  • Ember CLI v2.13 or above
  • Node.js v8 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

About

This addon provides string helpers for Ember templates and components.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •