ejs icon indicating copy to clipboard operation
ejs copied to clipboard

Export the Template class

Open ThisNameWasTaken opened this issue 6 years ago • 1 comments

Issue: Right now trying to access the Template class is not possible. I think that exposing the Template class would be useful since it would enable us to add new methods or override and expend existing ones without the need of having a local version of ejs and losing it as a npm dependency.

For instance if I would be trying to modify the parseTemplateText method right now I would have to store ejs as a (modified) local copy and not as a npm module.

const ejs = require('ejs'))

ejs.Template.prototype.parseTemplateText = function() { // Throws an error :/
    // ...
};

Fix: Simply exporting the function should do the trick. inside lib/ejs.js

module.exports.Template = Template;
function Template(text, opts) {

ThisNameWasTaken avatar Nov 24 '18 19:11 ThisNameWasTaken

This sounds reasonable. How about a PR that does this?

mde avatar Nov 24 '18 19:11 mde