Socket
Socket
Sign inDemoInstall

email-templates

Package Overview
Dependencies
Maintainers
2
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-templates - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

10

CHANGELOG.md

@@ -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

12

lib/main.js

@@ -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 = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc