index.js 814 B

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