A quick overview of helper functions from Handlebars.js documentation :
- A Handlebars helper call is a simple identifier (the name of the helper), followed by zero or more space-separated parameters.
- Parameters may be a simple String, number, boolean, or JSON object, as well as an optional sequence of key-value pairs (hash arguments) as the last parameter(s).
- The keys in hash arguments must be simple identifiers.
- The values in hash arguments are Handlebars expressions : simple identifiers, paths, or Strings.
- The current context, this, is always available to Handlebars helpers.
- The context may be a String, number, boolean, or a JSON data object.
- It is possible to pass an object nested within the current context as the context, such as this.url or this.id(see following examples of simple and block helpers).
- Block helpers are functions that can be called from anywhere in the template. They can invoke a block of the template zero or more times with a different context each time. They contain a context between {{#name}} and {{/name}}.
- Handlebars provides a final parameter to helpers named 'options'. The special object 'options' includes
- optional private data (options.data)
- optional key-value properties from the call (options.hash)
- ability to invoke itself (options.fn())
- ability to invoke the inverse of itself (options.inverse())
- It is recommended that the HTML String content returned from a helper is a SafeString.