/*
 * bemstyla
 * Copyright(c) 2015 Vladimir Rodkin <mail@vovanr.com>
 * MIT Licensed
 */

var _ = require('lodash');
var formatFileName = require('./format-file-name');
var ENV = require('./env');
var TERMS = ENV.TERMS;
var FORMATS = ENV.FORMATS;
var DEFAULT_FORMAT = ENV.DEFAULT_FORMAT;

var formatters = [
	/**
	* CSS
	*
	* @param {String} name
	* @return {String}
	*/
	function (name) {
		return '.' + name + ' {\n}';
	},

	/**
	* Stylus
	*
	* @param {String} name
	* @return {String}
	*/
	function (name) {
		return '.' + name + '\n    {}';
	}
];

function f(source, format) {
	format = FORMATS[String(format)] === undefined ? FORMATS[DEFAULT_FORMAT] : FORMATS[format];
	var formatter = formatters[format];
	return formatter(source);
}

module.exports = {
	/**
	* File content data
	*
	* @param {String} source
	* @param {String} [format='styl']
	* @return {Object}
	*/
	format: function (source, format) {
		var result = {};
		var fileNames = formatFileName.format(source);

		_.forEach(TERMS, function (term) {
			var content = '';
			var name = fileNames[term].file.name;
			if (name) {
				content = f(name, format);
			}
			result[term] = {
				file: {
					content: content
				}
			};
		});

		return result;
	}
};

@@ -550,18 +550,140 @@
 %5D;%0A%0A
-function f
+/**%0A * Format content%0A *%0A * @param %7BString%7D source%0A * @param %7BString%7D %5Bformat='styl'%5D%0A * @return %7BString%7D%0A */%0Afunction formatContent
 (sou
@@ -1225,16 +1225,28 @@
 tent = f
+ormatContent
 (name, f

Add format file content #22