templates
Version:
System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.
38 lines (32 loc) • 842 B
JavaScript
;
var utils = require('../utils');
/**
* Add a `renameKey` function to the given `app` instance.
*/
module.exports = function(config) {
config = config || {};
return function(app) {
this.define('renameKey', function(key, file, fn) {
if (typeof key === 'function') {
return this.renameKey(null, null, key);
}
if (typeof file === 'function') {
return this.renameKey(key, null, file);
}
if (typeof fn !== 'function') {
fn = this.options.renameKey;
}
if (typeof fn !== 'function') {
fn = config.renameKey;
}
if (typeof fn !== 'function') {
fn = utils.identity;
}
this.options.renameKey = fn;
if (typeof key === 'string') {
return fn.call(this, key, file);
}
return this;
});
};
};