diff --git a/README.md b/README.md index acb229b..4f9fb14 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ $ npm install --save @transomjs/transom-ejs-template ## Usage Transom-ejs-template is a simple module that provides a really simple way to send HTML (or text) formatted emails or even simple web pages.Using all the features of EJS, you can insert data into your templates or include other ejs templates etc. -After transom.initialize, an object is stored in the registry with 'transomTemplate' as the key. Each method will return a completely rendered template with all includes resoved and interpolated data. +After transom.initialize, an object is stored in the registry with 'transomTemplate' as the key. Each method will return a completely rendered template with all includes resolved and interpolated data. ### Render HTML templates renderHtmlTemplate(templateName, data, htmlOptions) diff --git a/lib/ejsHandler.js b/lib/ejsHandler.js index e24519b..1fd961f 100644 --- a/lib/ejsHandler.js +++ b/lib/ejsHandler.js @@ -20,8 +20,8 @@ module.exports = function TransomEjsHandler(server, options) { // Navigate up out of the node_modules folder, to the root. const templatePrefix = (data.environment === 'TESTING' ? path.join('..', 'test') : path.join('..', '..', '..', '..')); - const templatePath = path.join(templatePrefix, opts.templatePath || template.htmlTemplatePath || 'templateHtml'); - const filename = path.join(__dirname, templatePath, `${templateName}.ejs`); + const templatePath = opts.templatePath || template.htmlTemplatePath || 'templateHtml'; + const filename = path.join(__dirname, templatePrefix, templatePath, `${templateName}.ejs`); if (!fs.existsSync(filename)) { debug('HTML template not found', filename); @@ -47,11 +47,10 @@ module.exports = function TransomEjsHandler(server, options) { data.environment = (process.env.NODE_ENV || 'DEVELOPMENT').toUpperCase(); data.templateName = templateName; - // Navigate up out of the node_modules folder, to the root. const templatePrefix = (data.environment === 'TESTING' ? path.join('..', 'test') : path.join('..', '..', '..', '..')); - const templatePath = path.join(templatePrefix, opts.templatePath || template.emailTemplatePath || 'templateEmail'); - const filename = path.join(__dirname, templatePath, `${templateName}.ejs`); + const templatePath = opts.templatePath || template.emailTemplatePath || 'templateEmail'; + const filename = path.join(__dirname, templatePrefix, templatePath, `${templateName}.ejs`); if (!fs.existsSync(filename)) { debug('Email template not found', filename);