Last active
September 1, 2023 16:09
-
-
Save seeliang/5675ae8606e6c1db5adee24cbe0306a0 to your computer and use it in GitHub Desktop.
Revisions
-
seeliang revised this gist
Jul 9, 2021 . No changes.There are no files selected for viewing
-
seeliang created this gist
Jul 23, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ const ejs = require('ejs'); const fs = require('fs'); module.exports = ({template, config}) => { fs.readFile(template, 'utf8', (err, data) => { if (err) { console.log(err); return false; } var ejs_string = data, template = ejs.compile(ejs_string), html = template(config); fs.writeFile(template.replace('.ejs', '') + '.html', html, (err) => { if(err) { console.log(err); return false } return true; }); }); } // const url = 'https://my.name.com'; // ejs2html({template:__dirname+'/src/index.ejs', config:{url}})