Files
bower/lib/util/hogan-colors.js
billy gates 9825707837 Merge pull request #78 from sindresorhus/no-colors
Make it possible to disable colors
2012-10-16 23:13:20 -07:00

27 lines
924 B
JavaScript

// ==========================================
// BOWER: Hogan.js renderWithColors extension
// ==========================================
// Copyright 2012 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
var colors = require('colors');
var hogan = require('hogan.js');
var _ = require('lodash');
var nopt = require('nopt');
module.exports = hogan.Template.prototype.renderWithColors = function (context, partials, indent) {
if (nopt(process.argv).color === false) {
colors.mode = 'none';
}
context = _.extend({
yellow : function (s) { return s.yellow; },
green : function (s) { return s.green; },
cyan : function (s) { return s.cyan; },
grey : function (s) { return s.grey; },
red : function (s) { return s.red; }
}, context);
return this.ri([context], partials || {}, indent);
};