/**
 * Compile jade string.
 * @function lib.compile.compileJadeString
 * @see {@link http://jade-lang.com/reference/ | jade}
 * @param {string} src - Jade string to compile.
 * @param {object} data - Compile data.
 * @param {function} callback - Callback when done.
 * @author Taka Okunishi
 *
 */
var html = require('../html'),
    prettifyHtml = html.prettifyHtml;
module.exports = function (src, data, callback) {

    switch (arguments.length) {
        case 2:
            if (typeof(arguments[1]) === 'function') {
                callback = arguments[1];
            }
            break;
    }

    var jade = require('jade');
    data.pretty = false;
    try{
        jade.render(src, data, function (err, rendered) {
            callback(err, prettifyHtml(rendered));
        });
    } catch(e){
        callback(e);
    }
};