Processors

Prepares specifications for schematics.

📘

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

Processors update Specifications to meet the requirements of Schematics.

This allows more control and flexibility of your input. Some examples include:

  • manipulating data to add/remove data from a Specification
  • adding contents from a file to a Specification

Examples

In this example, a Schematic for routes expects an object of objects. Each object has a key which is used as the filename of each route. If an object doesn't have a URI value, it uses the key/name as the URI:

module.exports = function(val) {
  for (var name in val) {
    if (!val[name].uri) {
      val[name].uri = '/' + name;
    }
  }
  return val;
};

Did this page help you?