const Handlebars = require('handlebars');

Handlebars.registerHelper('removeBreak', (text) => {
  text = Handlebars.Utils.escapeExpression(text);
  text = text.replace(/(\r\n|\n|\r)/gm, ' ');
  return new Handlebars.SafeString(text);
});

const Template = class {
  constructor(templateString, data) {
    this.template = Handlebars.compile(templateString || '');
    this.data = data || {};
  }

  setTemplate(templateString) {
    this.template = Handlebars.compile(templateString || '');
  }

  parse(callback) {
    callback(this.template(this.data));
  }
};

module.exports = Template;

const Handlebars = require('handlebars');

Handlebars.registerHelper('removeBreak', (text) => {
  text = Handlebars.Utils.escapeExpression(text);
  text = text.replace(/(\r\n|\n|\r)/gm, ' ');
  return new Handlebars.SafeString(text);
});

const Template = class {
  constructor(templateString, data) {
    this.template = Handlebars.compile(templateString || '');
    this.data = data || {};
  }

  parse(callback) {
    callback(this.template(this.data));
  }
};

module.exports = Template;

Remove class method of Template
Remove class method of Template
