Helpers

Helpers help Engines do more.

๐Ÿ“˜

Since Helpers interact directly with Crystal, they must be written in JavaScript and/or CoffeeScript.

Helpers add logic to Engines such as:

  • capitalizing, pluralizing and singularizing text
  • adding conditions for showing/hiding blocks of text

Many template engines already use helpers, so this concept might be familiar to you.

Examples

Here is a simple example of changing the case of text:

var changechase = require('change-case');

module.exports = function(value, args) {
  return changechase[args[0]](value);
};