Skip to content

Instantly share code, notes, and snippets.

@seeliang
Last active September 1, 2023 16:09
Show Gist options
  • Select an option

  • Save seeliang/5675ae8606e6c1db5adee24cbe0306a0 to your computer and use it in GitHub Desktop.

Select an option

Save seeliang/5675ae8606e6c1db5adee24cbe0306a0 to your computer and use it in GitHub Desktop.

Revisions

  1. seeliang revised this gist Jul 9, 2021. No changes.
  2. seeliang created this gist Jul 23, 2020.
    18 changes: 18 additions & 0 deletions convert-ejs-to-html.js
    Original 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}})