Socket
Socket
Sign inDemoInstall

email-templates

Package Overview
Dependencies
Maintainers
3
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.2.0 to 1.2.1

examples/kuemailer/index.js

8

CHANGELOG.md

@@ -14,3 +14,10 @@ [antoinepairet]: https://github.com/antoinepairet

[jeduan]: https://github.com/jeduan
[kingcody]: https://github.com/kingcody
[remicastaing]: https://github.com/remicastaing
## 1.2.1 (2015-03-18)
* enhancement: [@kingcody][kingcody] Supports less 2.0
* enhancement: [@remicastaing][remicastaing] Allow using import in scss files
* enhancement: [@kewisch][kewisch] Allow passing options to juice
## 1.2.0 (2015-02-17)

@@ -20,3 +27,2 @@ * enhancement: [@jeduan][jeduan] Migrates back to Juice to support Node.js 0.12

* enhancement: [@gierschv][gierschv] Uses node-sass 2.0
*

@@ -23,0 +29,0 @@ ## 1.1.0 (2014-07-05)

12

lib/main.js

@@ -19,3 +19,3 @@ // node-email-templates

, zlib = require('zlib')
, _ = require('underscore')
, _ = require('lodash')
, tm = require('./templateManager')

@@ -39,3 +39,3 @@

// Ensure that `bufferType` is a valid `zlib` compression type
if (_.indexOf(validBufferTypes, bufferType) === -1) {
if (_.contains(validBufferTypes, bufferType)) {
throw new Error('`zlib.' + bufferType + '` does not exist or is not a valid buffer type')

@@ -79,4 +79,8 @@ } else {

// Make a copy of the juiceOptions object so we can add the stylesheet.
var juiceOptions = (typeof locals.juiceOptions === 'object' ? _.assign({}, locals.juiceOptions) : {})
juiceOptions.extraCss = (juiceOptions.extraCss || "") + stylesheet
// Inject available styles into HTML.
html = (stylesheet) ? juice(html, {extraCss: stylesheet}) : html
html = (stylesheet) ? juice(html, juiceOptions) : html

@@ -124,3 +128,3 @@ // Return a compressed buffer if needed.

// Ensure that `bufferType` is a valid `zlib` compression type
if (_.indexOf(validBufferTypes, bufferType) === -1) {
if (_.contains(validBufferTypes, bufferType)) {
throw new Error('`zlib.' + bufferType + '` does not exist or is not a valid buffer type')

@@ -127,0 +131,0 @@ } else {

@@ -14,3 +14,3 @@ /**

'.jade' : cons.jade.render,
'.ejs' : cons.ejs.render,
'.ejs' : renderEjs,
'.swig' : cons.swig.render,

@@ -52,2 +52,13 @@ '.hbs' : cons.handlebars.render,

function renderEjs(source, options, cb) {
var ejs = require('ejs')
try {
var tmpl = ejs.compile(source, options)
cb(null, tmpl(options))
} catch (err) {
console.error(err.stack)
cb(err)
}
}
// CSS pre-processors

@@ -58,10 +69,9 @@ function renderLess(source, locals, cb) {

var base = path.basename(locals.filename);
var parser = new(less.Parser)({
less.render(source, {
paths: [dir],
filename: base
});
parser.parse(source, function(err, tree) {
}, function(err, output) {
if (err) { return cb(err); }
cb(null, tree.toCSS());
cb(null, output.css || output);
});

@@ -90,2 +100,3 @@ }

locals.data = source
locals.includePaths = [locals.templatePath];
locals.success = successHandler

@@ -92,0 +103,0 @@ locals.error = errorHandler

{
"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.2.0",
"version": "1.2.1",
"author": "Nick Baugh <niftylettuce@gmail.com>",

@@ -49,3 +49,3 @@ "contributors": [

"engines": {
"node": "0.10.x"
"node": ">= 0.10"
},

@@ -63,3 +63,3 @@ "main": "lib/main.js",

"async": "^0.9.0",
"underscore": "^1.6.0",
"lodash": "^3.5.0",
"glob": "^4.0.0"

@@ -66,0 +66,0 @@ },

@@ -84,6 +84,27 @@ var emailTemplates = require('../lib/main')

it('html with inline CSS and text file', function(done) {
it('html with style element and juiceOptions', function(done) {
var html = '<style> h4 { color: red; }</style><h4><%= item%></h4>'
, css = 'h4 { color: blue; }';
fs.writeFileSync(path.join(templateDir, templateName, 'html.ejs'), html)
fs.writeFileSync(path.join(templateDir, templateName, 'style.ejs'), css)
var defaults = {
juiceOptions: { removeStyleTags: false }
}
emailTemplates(templateDir, defaults, 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(
'<style> h4 { color: red; }</style><h4 style=\"color: blue;\">test</h4>')
done()
});
});
});
it('html with inline CSS(ejs) and text file', function(done) {
var html = '<h4><%= item%></h4>'
, text = '<%= item%>'
, css = 'h4 { color: #ccc }'
, css = 'h4 { color: <%= color %> }'
fs.writeFileSync(path.join(templateDir, templateName, 'html.ejs'), html)

@@ -94,3 +115,3 @@ fs.writeFileSync(path.join(templateDir, templateName, 'text.ejs'), text)

emailTemplates(templateDir, function(err, template) {
template(templateName, {item: 'test'}, function(err, html, text) {
template(templateName, {item: 'test', color: '#ccc'}, function(err, html, text) {
expect(err).to.be.null

@@ -105,3 +126,21 @@ expect(text).to.equal('test')

it('html with inline CSS and text file with custom names', function(done) {
it('html(jade) with inline CSS(less)', function(done) {
var html = 'h4= item'
, text = '<%= item%>'
, css = '@color: #ccc; h4 { color: @color }'
fs.writeFileSync(path.join(templateDir, templateName, 'html.jade'), html)
fs.writeFileSync(path.join(templateDir, templateName, 'style.less'), css)
emailTemplates(templateDir, function(err, template) {
template(templateName, {item: 'test'}, function(err, html, text) {
expect(err).to.be.null
expect(text).to.equal(false)
expect(html).to.equal(
'<h4 style=\"color: #cccccc;\">test</h4>')
done()
})
})
})
it('html with inline CSS and text file with custom names', function(done) {
var html = '<h4><%= item%></h4>'

@@ -108,0 +147,0 @@ , text = '<%= item%>'

Sorry, the diff of this file is not supported yet

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