register.js 445 B

12345678910111213
  1. var pug = require('./');
  2. var resolvedPug = JSON.stringify(require.resolve('./'));
  3. function compileTemplate(module, filename) {
  4. var template = pug.compileFileClient(filename, {inlineRuntimeFunctions: false});
  5. var body = "var pug = require(" + resolvedPug + ").runtime;\n\n" +
  6. "module.exports = " + template + ";";
  7. module._compile(body, filename);
  8. }
  9. if (require.extensions) {
  10. require.extensions['.pug'] = compileTemplate
  11. };