exports.tags = require('./lib/tags');
exports.filters = require('./lib/filters');

exports.useFilter = function (swig, filter) {
  var f = exports.filters[filter];
  if (!f) {
    throw new Error('Filter "' + filter + '" does not exist.');
  }
  swig.setFilter(filter, f);
};

exports.useTag = function (swig, tag) {
  var t = exports.tags[tag];
  if (!t) {
    throw new Error('Tag "' + tag + '" does not exist.');
  }
  swig.setTag(tag, t.parse, t.compile, t.ends, t.blockLevel);
  if (t.ext) {
    swig.setExtension(t.ext.name, t.ext.obj);
  }
};

@@ -1,280 +1,1129 @@
-exports.tags = require('./lib/tags');%0Aexports.filters = require('./lib/filters');%0A%0Aexports.useFilter = function (swig, filter) %7B%0A  var f = exports.filters%5Bfilter%5D;%0A  if (!f) %7B%0A    throw new Error('Filter %22' + filter + '%22 does not exist.');%0A  %7D%0A  swig.setFilter(filter, f);%0A%7D;%0A
+/**%0A * Raw tag objects.%0A * @type %7Bobject%7D%0A */%0Aexports.tags = require('./lib/tags');%0A%0A/**%0A * Raw filter methods.%0A * @type %7Bobject%7D%0A */%0Aexports.filters = require('./lib/filters');%0A%0A/**%0A * Add an Extras filter to your swig instance.%0A *%0A * @example%0A * var swig = require('swig'),%0A *   extras = require('swig-extras');%0A * extras.useFilter(swig, 'markdown');%0A *%0A * @param  %7Bobject%7D swig   Swig instance.%0A * @param  %7Bstring%7D filter Extras filter name.%0A * @return %7Bundefined%7D%0A * @throws %7BError%7D If Extras does not have a filter with the given name.%0A */%0Aexports.useFilter = function (swig, filter) %7B%0A  var f = exports.filters%5Bfilter%5D;%0A  if (!f) %7B%0A    throw new Error('Filter %22' + filter + '%22 does not exist.');%0A  %7D%0A  swig.setFilter(filter, f);%0A%7D;%0A%0A/**%0A * Add an Extras tag to your swig instance.%0A *%0A * @example%0A * var swig = require('swig'),%0A *   extras = require('swig-extras'),%0A *   mySwig = new swig.Swig();%0A * extras.useTag(mySwig, 'markdown');%0A *%0A * @param  %7Bobject%7D swig   Swig instance.%0A * @param  %7Bstring%7D tag    Extras tag name.%0A * @return %7Bundefined%7D%0A * @throws %7BError%7D If Extras does not have a tag with the given name.%0A */
 %0Aexp

add comments