«««< HEAD Build Status

transformers

String/Data transformations for use in templating libraries, static site generators and web frameworks. This gathers the most useful transformations you can apply to text or data into one library with a consistent API. Transformations can be pretty much anything but most are either compilers or templating engines.

Supported transforms

To use each of these transforms you will also need to install the associated npm module for that transformer.

Template engines

Stylesheet Languages

Minifiers

Other

Pull requests to add more transforms will always be accepted providing they are open-source, come with unit tests, and don’t cause any of the tests to fail.

API

The exported object transformers is a collection of named transformers. To access an individual transformer just do:

  var transformer = require('transformers')['transformer-name']

Transformer

The following options are given special meaning by transformers:

Transformer.engines

Returns an array of engines that can be used to power this transformer. The first of these that’s installed will be used for the transformation.

To enable a transformation just take [engine] = Transformer.engines[0] and then do npm install [engine]. If [engine] is . there is no need to install an engine from npm to use the transformer.

Transformer.render(str, options, cb)

Tranform the string str using the Transformer with the provided options and call the callback cb(err, res).

If no cb is provided, this method returns a promises/A+ promise.

Transformer.renderSync(str, options)

Synchronous version of Transformer.render

Transformer.renderFile(filename, options, cb)

Reads the file at filename into str and sets options.filename = filename then calls Transform.render(str, options, cb).

If no cb is provided, this method returns a promises/A+ promise.

Tranformer.renderFileSync(filename, options)

Synchronous version of Tranformer.renderFile

Transformer.outputFormat

A string, one of:

Adding to this list will not result in a major version change, so you should handle unexpected types gracefully (I’d suggest default to assuming 'text').

Transformer.sync

true if the transformer can be used syncronously, false otherwise.

Libraries that don’t work synchronously

The following transformations will always throw an exception if you attempt to run them synchronously:

  1. dust
  2. qejs
  3. html2jade

The following transformations sometimes throw an exception if run syncronously, typically they only throw an exception if you are doing something like including another file. If you are not doing the things that cause them to fail then they are consistently safe to use syncronously.

The following libraries look like they might sometimes throw exceptions when used syncronously (if you read the source) but they never actually do so:

String/Data transformations for use in templating libraries, static site generators and web frameworks. This gathers the most useful transformations you can apply to text or data into one library with a consistent API. Transformations can be pretty much anything but most are either compilers or templating engines.

Supported transforms

To use each of these transforms you will also need to install the associated npm module for that transformer.

Template engines

Stylesheet Languages

Minifiers

Other

Pull requests to add more transforms will always be accepted providing they are open-source, come with unit tests, and don’t cause any of the tests to fail.

API

The exported object transformers is a collection of named transformers. To access an individual transformer just do:

  var transformer = require('transformers')['transformer-name']

Transformer

The following options are given special meaning by transformers:

Transformer.engines

Returns an array of engines that can be used to power this transformer. The first of these that’s installed will be used for the transformation.

To enable a transformation just take [engine] = Transformer.engines[0] and then do npm install [engine]. If [engine] is . there is no need to install an engine from npm to use the transformer.

Transformer.render(str, options, cb)

Tranform the string str using the Transformer with the provided options and call the callback cb(err, res).

If no cb is provided, this method returns a promises/A+ promise.

Transformer.renderSync(str, options)

Synchronous version of Transformer.render

Transformer.renderFile(filename, options, cb)

Reads the file at filename into str and sets options.filename = filename then calls Transform.render(str, options, cb).

If no cb is provided, this method returns a promises/A+ promise.

Tranformer.renderFileSync(filename, options)

Synchronous version of Tranformer.renderFile

Transformer.outputFormat

A string, one of:

Adding to this list will not result in a major version change, so you should handle unexpected types gracefully (I’d suggest default to assuming 'text').

Transformer.sync

true if the transformer can be used syncronously, false otherwise.

Libraries that don’t work synchronously

The following transformations will always throw an exception if you attempt to run them synchronously:

  1. dust
  2. qejs
  3. html2jade

The following transformations sometimes throw an exception if run syncronously, typically they only throw an exception if you are doing something like including another file. If you are not doing the things that cause them to fail then they are consistently safe to use syncronously.

The following libraries look like they might sometimes throw exceptions when used syncronously (if you read the source) but they never actually do so: