Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ejs = require('ejs')
  2.  
  3. // Pleb way
  4. ejs.fileLoader = loadFile;
  5.  
  6. function loadFile(filePath) {
  7.   const regex = /^[ \t]*#(.*)$/mg;
  8.   const contents = fs.readFileSync(filePath);
  9.  
  10.   return contents.replace(regex, '<%_$1_%>');
  11. };
  12.  
  13. // l33t hacker way
  14. ejs.fileLoader = (p) => fs.readFileSync(p).replace(/^[ \t]*#(.*)$/mg, '<%_$1_%>');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement