Permalink
Browse files

Removed requirement for style.css and text.ejs, closes #1

  • Loading branch information...
1 parent bca597e commit 897c58b479af4f93255604652d6765511805ab85 @niftylettuce niftylettuce committed Sep 12, 2012
Showing with 81 additions and 9 deletions.
  1. +53 −0 .jshintrc
  2. +6 −5 Readme.md
  3. +17 −3 lib/main.js
  4. +5 −1 package.json
View
@@ -0,0 +1,53 @@
+
+<!-- saved from url=(0120)https://raw.github.com/niftylettuce/teelaunch/master/.jshintrc?login=niftylettuce&token=f8f1993df0837b0f393b0825e7f95fe1 -->
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">{
+ "predef": [
+ "jasmine",
+ "spyOn",
+ "it",
+ "console",
+ "describe",
+ "expect",
+ "beforeEach",
+ "waits",
+ "waitsFor",
+ "runs",
+ "alert",
+ "confirm",
+ "Modernizr",
+ "impress",
+ "exports",
+ "self"
+ ],
+
+ "node" : true,
+ "es5" : true,
+ "browser" : true,
+ "jquery": true,
+
+ "boss" : false,
+ "curly": false,
+ "debug": false,
+ "devel": false,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": true,
+ "laxcomma": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "indent": 2,
+ "asi": true
+}
+</pre></body></html>
View
@@ -1,9 +1,10 @@
-# node-email-templates <sup>0.0.2</sup>
+# node-email-templates <sup>0.0.3</sup>
Node.js module for rendering beautiful emails with [ejs][1] templates and email-friendly inline CSS using [juice][2].
-**NEW**: Added support for custom EJS options such as opening and closing tags (instead of `<%` and `%>`). See documentation below for more information.
+**New in v0.0.3**:
+* Removed requirement for `style.css` and `text.ejs` files with compatibility in `node` v0.6.x to v0.8.x (utilizes `path.exists` vs. `fs.exists` respectively).
## Email Templates
@@ -32,9 +33,9 @@ npm install email-templates-windows
2. Create a folder called `templates` inside your root directory (or elsewhere).
3. For each of your templates, respectively name and create a folder inside the `templates` folder.
4. Add the following files inside the template's folder:
- * `html.ejs` - html + [ejs][1] version of your email template
- * `text.ejs` - text + [ejs][1] version of your email template
- * `style.css` - stylesheet for the template, which will render `html.ejs` with inline CSS (optional)
+ * `html.ejs` - html + [ejs][1] version of your email template (**required**)
+ * `text.ejs` - text + [ejs][1] version of your email template (**optional**)
+ * `style.css` - stylesheet for the template, which will render `html.ejs` with inline CSS (**optional**)
5. Utilize one of the examples below for your respective email module and start sending beautiful emails!
View
@@ -113,12 +113,12 @@ var EmailTemplate = function(templateDirectory, defaults, done) {
that.text = path.join(templatePath, 'text.ejs');
that.stylesheet = path.join(templatePath, 'style.css');
- async.map([that.text, that.stylesheet], fs.stat, function(err, results) {
+ async.map([that.text, that.stylesheet], checkExists, function(err, results) {
if (err) return callback(err);
- if (!results[0].isFile()) that.text = false;
- if (!results[1].isFile()) that.stylesheet = false;
+ that.text = results[0];
+ that.stylesheet = results[1];
if (that.text && that.stylesheet) {
async.map([that.text, that.stylesheet], fs.readFile, function(err, results) {
@@ -149,10 +149,24 @@ var EmailTemplate = function(templateDirectory, defaults, done) {
}
});
+
+
});
});
});
});
+
+ function checkExists(item, callback) {
+ function cb(exists) {
+ return callback(null, exists)
+ }
+ // node >= v0.8.x
+ if (fs.exists) return fs.exists(item, cb)
+ // other versions of node fallback to path.exists
+ return path.exists(item, cb)
+ }
+
+
});
};
View
@@ -1,7 +1,7 @@
{
"name": "email-templates"
, "description": "Node.js module for rendering beautiful emails with ejs templates and email-friendly inline CSS using juice."
- , "version": "0.0.2"
+ , "version": "0.0.3"
, "author": "Nick Baugh <niftylettuce@gmail.com>"
, "contributors": [
{ "name": "Nick Baugh", "email": "niftylettuce@gmail.com" }
@@ -22,4 +22,8 @@
, "async": "0.1.22"
, "underscore": "1.3.3"
}
+ , "devDependencies": {
+ "nodemailer": "0.3.27"
+ , "postmark": "0.1.6"
+ }
}

5 comments on commit 897c58b

@davidandrewcope

When I upgrade to 0.0.3, and put the style.css or text.ejs back in I get an exception:
fs.js:330
binding.open(pathModule._makeLong(path),
^
TypeError: path must be a string

I think this change may have broken it. I'm on node v0.8.3.

Thanks

@niftylettuce
Member

rolling back

@niftylettuce
Member

should be all fixed, try version 0.0.4 for simplicity

@niftylettuce
Member

@davidandrewcope i had forgot to put in a conditional check, should be OK now in version 0.0.4, lmk if otherwise

@davidandrewcope

Yep, working now. Thanks!

Please sign in to comment.