var renderer = require('./extend').renderer.list(),
  rendererSync = require('./extend').rendererSync.list(),
  helper = require('./extend').helper.list(),
  async = require('async'),
  path = require('path'),
  _ = require('lodash'),
  util = require('./util'),
  file = util.file,
  yfm = util.yfm,
  cache = {};

var render = exports.render = function(data, options, callback){
  if (_.isFunction(options)){
    callback = options;
    options = {};
  }

  var text = data.text,
    source = data.path;

  async.series([
    function(next){
      if (text){
        next(null);
      } else if (source){
        file.read(source, function(err, content){
          if (err) return callback(err);
          text = content;
          next();
        });
      } else {
        callback(new Error('No input file or string'));
      }
    },
    function(next){
      var ext = data.engine || path.extname(data.path).substring(1);

      if (ext && renderer.hasOwnProperty(ext)){
        renderer[ext]({path: source, text: text}, options, callback);
      } else {
        callback(null, text);
      }
    }
  ]);
};

var renderSync = exports.renderSync = function(data, options){
  if (data.text){
    var text = data.text;
  } else if (data.path){
    var text = file.readSync(data.path);
  } else {
    return;
  }

  var ext = data.engine || path.extname(data.path).substring(1);

  if (ext && rendererSync.hasOwnProperty(ext)){
    return rendererSync[ext]({path: data.path, text: text}, options);
  }
};
@@ -1501,8 +1501,1068 @@
 ;%0A  %7D%0A%7D;
+%0A%0Avar renderFile = exports.__express = function(source, options, callback)%7B%0A  if (_.isFunction(options))%7B%0A    callback = options;%0A    options = %7B%7D;%0A  %7D%0A%0A  async.waterfall(%5B%0A    function(next)%7B%0A      next(null, options.cache ? cache%5Bsource%5D : false);%0A    %7D,%0A    function(data, next)%7B%0A      if (data)%7B%0A        next(null, data);%0A      %7D else %7B%0A        file.read(source, function(err, content)%7B%0A          if (err) return callback(err);%0A          console.log(content);%0A          var data = cache%5Bsource%5D = yfm(content);%0A          next(null, data);%0A        %7D);%0A      %7D%0A    %7D,%0A    function(data, next)%7B%0A      var layout = data.layout %7C%7C options.layout,%0A        content = data._content,%0A        ext = options.settings%5B'view engine'%5D;%0A%0A      if (layout)%7B%0A        var layoutPath = path.dirname(source) + '/' + layout;%0A        if (!path.extname(layoutPath)) layoutPath += '.' + ext;%0A        renderFile(layoutPath, _.extend(options, %7Bbody: content%7D), callback);%0A      %7D else %7B%0A        renderer%5Bext%5D(%7Bpath: source, text: content%7D, options, callback);%0A      %7D%0A    %7D%0A  %5D);%0A%7D;

render.__express