email-templates
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -9,3 +9,13 @@ [antoinepairet]: https://github.com/antoinepairet | ||
[jscharlach]: https://github.com/jscharlach | ||
[skimmmer]: https://github.com/skimmmer | ||
[jksdua]: https://github.com/jksdua | ||
[DesignByOnyx]: https://github.com/DesignByOnyx | ||
[anotherjazz]: https://github.com/anotherjazz | ||
## 1.1.0 (2014-07-05) | ||
* enhancement: [@DesignByOnyx][DesignByOnyx]: Add support for filename prefix | ||
* enhancement: [@skimmmer][skimmmer]: Add dust-linkedin template engine | ||
* enhancement: [@anotherjazz][anotherjazz]: Add emblem template engine | ||
* development: [@jksdua][jksdua]: Update node-sass version | ||
## 1.0.0 (2014-05-27) | ||
@@ -12,0 +22,0 @@ * bugfix: [@jscharlach][jscharlach]: Fix template scope issues |
@@ -66,5 +66,5 @@ // node-email-templates | ||
, cssOpts = { source: stylesheet, locals: locals }; | ||
htmlOpts.filename = glob.sync(path.join(locals.templatePath, 'html*'))[0]; | ||
textOpts.filename = glob.sync(path.join(locals.templatePath, 'text*'))[0]; | ||
cssOpts.filename = glob.sync(path.join(locals.templatePath, 'style*'))[0]; | ||
htmlOpts.filename = glob.sync(path.join(locals.templatePath, '*html.*'))[0]; | ||
textOpts.filename = glob.sync(path.join(locals.templatePath, '*text.*'))[0]; | ||
cssOpts.filename = glob.sync(path.join(locals.templatePath, '*style.*'))[0]; | ||
@@ -174,3 +174,3 @@ // Render all templates and stylesheets. | ||
// Ensure that at least an html file exists inside | ||
scopeInfo.html = glob.sync(templatePath + '/html*')[0] || ''; | ||
scopeInfo.html = glob.sync(templatePath + '/*html.*')[0] || ''; | ||
fs.stat(scopeInfo.html, function(err, stats) { | ||
@@ -191,4 +191,4 @@ | ||
// Set asset paths | ||
scopeInfo.text = glob.sync(templatePath + '/text*')[0] || ''; | ||
scopeInfo.stylesheet = glob.sync(templatePath + '/style*')[0] || ''; | ||
scopeInfo.text = glob.sync(templatePath + '/*text.*')[0] || ''; | ||
scopeInfo.stylesheet = glob.sync(templatePath + '/*style.*')[0] || ''; | ||
@@ -195,0 +195,0 @@ async.map([scopeInfo.text, scopeInfo.stylesheet], checkExists, function(err, results) { |
@@ -12,2 +12,4 @@ /** | ||
, handlebars = require('handlebars') | ||
, emblem = require('emblem') | ||
, dust = require('dustjs-linkedin') | ||
, less = require('less') | ||
@@ -26,2 +28,4 @@ , sass = require('node-sass') | ||
'.handlebars' : renderHandlebars, | ||
'.emblem' : renderEmblem, | ||
'.dust' : renderDust, | ||
// CSS pre-processors | ||
@@ -64,2 +68,10 @@ '.less' : renderLess, | ||
} | ||
function renderEmblem(source, locals, cb) { | ||
var template = emblem.compile(handlebars, source) | ||
cb(null, template(locals)) | ||
} | ||
function renderDust(source, locals, cb) { | ||
dust.loadSource(dust.compile(source, 'tmp')); | ||
dust.render('tmp', locals, cb); | ||
} | ||
@@ -66,0 +78,0 @@ // CSS pre-processors |
{ | ||
"name": "email-templates", | ||
"description": "Node.js module for rendering beautiful emails with ejs, jade, swig, hbs, or handlebars templates and email-friendly inline CSS using juice.", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Nick Baugh <niftylettuce@gmail.com>", | ||
@@ -59,6 +59,8 @@ "contributors": [ | ||
"handlebars": "^1.3.0", | ||
"emblem": "~0.3.16", | ||
"dustjs-linkedin": "^2.4.0", | ||
"glob": "^4.0.0", | ||
"stylus": "^0.45.1", | ||
"styl": "^0.2.7", | ||
"node-sass": "^0.8.6", | ||
"node-sass": "^0.9.3", | ||
"less": "^1.7.0" | ||
@@ -65,0 +67,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
# node-email-templates [![Build Status](https://travis-ci.org/niftylettuce/node-email-templates.png?branch=master)](https://travis-ci.org/niftylettuce/node-email-templates) [![NPM version](https://badge.fury.io/js/email-templates.png)](http://badge.fury.io/js/email-templates-windows) [![Gittip](http://img.shields.io/gittip/niftylettuce.png)](https://www.gittip.com/niftylettuce/) | ||
# node-email-templates [![Build Status](https://travis-ci.org/niftylettuce/node-email-templates.png?branch=master)](https://travis-ci.org/niftylettuce/node-email-templates) [![NPM version](https://badge.fury.io/js/email-templates.png)](http://badge.fury.io/js/email-templates) | ||
@@ -8,2 +8,4 @@ Node.js module for rendering beautiful emails with your template engine and CSS pre-processor of choice coupled with email-friendly inline CSS using [juice][2]. | ||
[handlebars]: https://github.com/wycats/handlebars.js | ||
[emblem]: https://github.com/machty/emblem.js | ||
[dust-linkedin]: https://github.com/linkedin/dustjs | ||
[less]: http://lesscss.org/ | ||
@@ -62,2 +64,4 @@ [sass]: http://sass-lang.com/ | ||
* [handlebars][handlebars] | ||
* [emblem][emblem] | ||
* [dust-linkedin][dust-linkedin] | ||
@@ -94,2 +98,4 @@ #### Supported CSS Pre-processors | ||
* `style.{{CSS pre-processor}}` - See [supported CSS pre-processors](#supported-css-pre-processors) (**optional**) | ||
* **NEW:** You may prefix any file name with anything you like to help you identify the files more easily in your IDE. | ||
The only requirement is that the filename contains `html.`, `text.`, and `style.` respectively. | ||
5. You may use the `include` directive from ejs (for example, to include a common header or footer). See the `/examples` folder for details. | ||
@@ -417,3 +423,3 @@ 6. Utilize one of the examples below for your respective email module and start sending beautiful emails! | ||
* Jason Sims <sims.jrobert@gmail.com> | ||
* Miguel Mota <hello@miguelmota.com> | ||
* Miguel Mota <hello@miguelmota.com> | ||
@@ -420,0 +426,0 @@ [Full Contributors List](https://github.com/niftylettuce/node-email-templates/graphs/contributors) |
@@ -38,2 +38,15 @@ var emailTemplates = require('../lib/main') | ||
}) | ||
it('html file with custom name', function(done) { | ||
var html = '<h4><%= item%></h4>' | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-html.ejs'), html) | ||
emailTemplates(templateDir, function(err, template) { | ||
template(templateName, {item: 'test'}, function(err, html, text) { | ||
expect(err).to.be.null | ||
expect(text).to.be.false | ||
expect(html).to.equal('<h4>test</h4>') | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -55,3 +68,19 @@ it('html and text files', function(done) { | ||
}) | ||
it('html and text files with custom names', function(done) { | ||
var html = '<h4><%= item%></h4>' | ||
, text = '<%= item%>' | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-html.ejs'), html) | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-text.ejs'), text) | ||
emailTemplates(templateDir, function(err, template) { | ||
template(templateName, {item: 'test'}, function(err, html, text) { | ||
expect(err).to.be.null | ||
expect(html).to.equal('<h4>test</h4>') | ||
expect(text).to.equal('test') | ||
done() | ||
}) | ||
}) | ||
}) | ||
it('html with inline CSS and text file', function(done) { | ||
@@ -75,3 +104,22 @@ var html = '<h4><%= item%></h4>' | ||
}) | ||
it('html with inline CSS and text file with custom names', function(done) { | ||
var html = '<h4><%= item%></h4>' | ||
, text = '<%= item%>' | ||
, css = 'h4 { color: #ccc }' | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-html.ejs'), html) | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-text.ejs'), text) | ||
fs.writeFileSync(path.join(templateDir, templateName, 'custom-filename-style.ejs'), css) | ||
emailTemplates(templateDir, function(err, template) { | ||
template(templateName, {item: 'test'}, function(err, html, text) { | ||
expect(err).to.be.null | ||
expect(text).to.equal('test') | ||
expect(html).to.equal( | ||
'<html><body><h4 style=\"color: #ccc;\">test</h4></body></html>') | ||
done() | ||
}) | ||
}) | ||
}) | ||
it('batch templates', function(done) { | ||
@@ -137,2 +185,14 @@ var html = '<h4><%= item%></h4>' | ||
it('on misnamed html file', function(done) { | ||
fs.writeFileSync(path.join(templateDir, templateName, 'html-custom-filename.ejs'), '') | ||
emailTemplates(templateDir, function(err, template) { | ||
template(templateName, {item: 'test'}, function(err, html, text) { | ||
expect(html).to.be.undefined | ||
expect(text).to.be.undefined | ||
expect(err.code).to.equal('ENOENT') | ||
done() | ||
}) | ||
}) | ||
}) | ||
it('on empty html file', function(done) { | ||
@@ -139,0 +199,0 @@ fs.writeFileSync(path.join(templateDir, templateName, 'html.ejs'), '') |
@@ -84,2 +84,32 @@ var tm = require('../lib/templateManager') | ||
it('should render emblem', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.emblem', | ||
source: 'h1 {{ item }}\nh1 {{ engine }}' | ||
} | ||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test</h1><h1>.emblem</h1>'); | ||
done() | ||
}) | ||
}) | ||
it('should render dust', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.dust', | ||
source: '<h1>{item}\n</h1><h1>{engine}</h1>' | ||
} | ||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test</h1><h1>.dust</h1>'); | ||
done() | ||
}) | ||
}) | ||
it('should render less', function(done) { | ||
@@ -86,0 +116,0 @@ var opts = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55760
894
445
14
+ Addeddustjs-linkedin@^2.4.0
+ Addedemblem@~0.3.16
+ AddedStringScanner@0.0.3(transitive)
+ Addedansi-regex@0.2.1(transitive)
+ Addedansi-styles@1.1.0(transitive)
+ Addedanymatch@1.3.2(transitive)
+ Addedarr-diff@2.0.04.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.2.10.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedasync-each@1.0.6(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbraces@1.8.52.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedchalk@0.5.1(transitive)
+ Addedchokidar@1.5.2(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcli@1.0.1(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcommander@2.3.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.0.0(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddiff@1.0.8(transitive)
+ Addeddustjs-linkedin@2.7.5(transitive)
+ Addedemblem@0.3.19(transitive)
+ Addedescape-string-regexp@1.0.21.0.5(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedexpand-brackets@0.1.52.1.4(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@0.3.22.0.4(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.44.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedformatio@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@1.2.13(transitive)
+ Addedget-stdin@3.0.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedgrowl@1.8.1(transitive)
+ Addedhandlebars@2.0.0(transitive)
+ Addedhas-ansi@0.1.0(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-number@2.1.03.0.04.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedkind-of@4.0.06.0.3(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.113.1.10(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedmkdirp@0.5.0(transitive)
+ Addedmocha@1.21.5(transitive)
+ Addedms@0.6.2(transitive)
+ Addednan@1.3.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addednode-sass@0.9.6(transitive)
+ Addednode-sass-middleware@0.3.1(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject-assign@1.0.0(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreaddirp@2.2.1(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedsamsam@1.1.3(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedshelljs@0.3.0(transitive)
+ Addedsinon@1.10.3(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@0.3.0(transitive)
+ Addedsupports-color@0.2.0(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addedyargs@1.3.3(transitive)
- Removedansi-styles@1.0.0(transitive)
- Removedchalk@0.4.0(transitive)
- Removedcommander@2.0.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddiff@1.0.7(transitive)
- Removedformatio@1.1.1(transitive)
- Removedgrowl@1.7.0(transitive)
- Removedhas-color@0.1.7(transitive)
- Removedlolex@1.3.2(transitive)
- Removedmocha@1.18.2(transitive)
- Removedms@2.1.3(transitive)
- Removednan@0.8.0(transitive)
- Removednode-sass@0.8.6(transitive)
- Removedsamsam@1.1.2(transitive)
- Removedsinon@1.17.7(transitive)
- Removedstrip-ansi@0.1.1(transitive)
Updatednode-sass@^0.9.3