index.js 588 B

123456789101112131415161718
  1. var template = require('art-template/dist/template');
  2. module.exports = function(source) {
  3. this.cacheable && this.cacheable()
  4. var ANONYMOUS_RE = /^function\s+anonymous/
  5. template.onerror = function(e) {
  6. var message = 'Template Error\n\n';
  7. for (var name in e) {
  8. message += '<' + name + '>\n' + e[name] + '\n\n';
  9. }
  10. throw new SyntaxError(message)
  11. }
  12. var render = template.compile(source, {}).toString().replace(ANONYMOUS_RE, 'function');
  13. return 'module.exports = require("art-template/loader/runtime")(' + render + ');';
  14. }