Helper Functions

Helper Functions

These are functions that help in dealing with the variables. in addition to Built-in Helpers in Handlebars:

length

Get the length of a string.

Example
Code

Output
5

substring

Get a substring from a string between the start and end indices.

Example
Code

Output
hello

replace

Replace all occurrences of a search string with a replace string in the given string.

Example
Code

Output
hello there

date

Get the current date and time as a string.

Example
Code

Output
[current date and time]

truncate

Truncate a string to a specified length and append ‘…’.

Example
Code

Output
This is a ...

tail

Get the last specified number of characters from a string, prepending ‘…’.

Example
Code

Output
...ong text.  

split

Split a string into an array using the given separator.

Example
Code
  
Output
["apple","banana","orange"]  

join

Join an array of strings using the given separator.

Example
Code
    
Output
apple, banana, orange    

unique

Return an array containing only unique elements from the input array.

Example
Code
     
Output
["apple","banana","orange"]     

trim

Trim whitespace from both ends of a string.

Example
Code
    
Output
hello world    

getRandomFile

Get a random file matching the given pattern with content length within the specified range.

Example
Code

Output
filename: [random file name] 
content: [random file content]
Note

More helper functions will added in the future releases. Our discord server is a great place to ask for assistance or suggest new features.

Table of contents

Local Graph

Mentions