var fs = require('fs');

module.exports = function(opts) {
  this.options = opts;

  if (!opts.handlebars) this.options.handlebars = require('handlebars');

  if (opts.template) {
    var fileData = fs.readFileSync(this.options.template);
    this.template = this.options.handlebars.compile(fileData.toString(), {noEscape: true});
  }

  return this;
}

var fs = require('fs');

module.exports = function(opts) {
  var fileData;
  this.options = opts;

  if (!opts.handlebars) this.options.handlebars = require('handlebars');

  if (opts.template) {
    try {
      fileData = fs.readFileSync(this.options.template);
    }
    catch (e) {
      throw new Error('Error loading Supercollider template file: ' + e.message);
    }

    this.template = this.options.handlebars.compile(fileData.toString(), {noEscape: true});
  }
  else {
    throw new Error('No path to a template was set in Supercollider.config().');
  }

  return this;
}

Throw errors if a template is not set, or if a template can't be loaded