index.js 792 B

12345678910111213141516171819202122232425
  1. // USAGE:
  2. // var handlebars = require('handlebars');
  3. /* eslint-disable no-var */
  4. // var local = handlebars.create();
  5. var handlebars = require('../dist/cjs/handlebars')['default'];
  6. var printer = require('../dist/cjs/handlebars/compiler/printer');
  7. handlebars.PrintVisitor = printer.PrintVisitor;
  8. handlebars.print = printer.print;
  9. module.exports = handlebars;
  10. // Publish a Node.js require() handler for .handlebars and .hbs files
  11. function extension(module, filename) {
  12. var fs = require('fs');
  13. var templateString = fs.readFileSync(filename, 'utf8');
  14. module.exports = handlebars.compile(templateString);
  15. }
  16. /* istanbul ignore else */
  17. if (typeof require !== 'undefined' && require.extensions) {
  18. require.extensions['.handlebars'] = extension;
  19. require.extensions['.hbs'] = extension;
  20. }