jade-attachfilter

Attach new filters to Jade

A convinience module for attaching arbitrary filters to Jade.

Installation

npm install jade-attachfilter

Usage

// Add a filter 
var attachfilter = require('jade-attachfilter');
attachfilter('uppercase', function (stroptions) {
  return str.toUpperCase();
});
 
// Use filter 
var str  = ':uppercase\n  hello world';
var html = jade.compile(jade)();

You can make Jade pass options to your filter by doing:

:myfilter(foo=bar, baz=hey)
  Do stuff with this text block.
attachfilter('myfilter', function (stroptions) {
  if (options.foo === 'bar') {
    return 'no foo for you';
  }
  else {
    return str;
  }
});

License

ISC