Browse Source

migrate templates to mustache

activeAddress
Ivan Socolsky 10 years ago
parent
commit
638b90ed18
  1. 7
      lib/emailservice.js
  2. 4
      lib/templates/new_copayer.plain
  3. 4
      lib/templates/new_incoming_tx.plain
  4. 4
      lib/templates/new_outgoing_tx.plain
  5. 4
      lib/templates/new_tx_proposal.plain
  6. 4
      lib/templates/txp_finally_rejected.plain
  7. 4
      lib/templates/wallet_complete.plain

7
lib/emailservice.js

@ -3,6 +3,7 @@
var _ = require('lodash'); var _ = require('lodash');
var $ = require('preconditions').singleton(); var $ = require('preconditions').singleton();
var async = require('async'); var async = require('async');
var Mustache = require('mustache');
var log = require('npmlog'); var log = require('npmlog');
log.debug = log.verbose; log.debug = log.verbose;
var fs = require('fs'); var fs = require('fs');
@ -98,8 +99,8 @@ EmailService.prototype._readTemplate = function(filename, cb) {
} }
var lines = template.split('\n'); var lines = template.split('\n');
return cb(null, { return cb(null, {
subject: _.template(lines[0]), subject: lines[0],
body: _.template(_.rest(lines).join('\n')), body: _.rest(lines).join('\n'),
}); });
}); });
}; };
@ -107,7 +108,7 @@ EmailService.prototype._readTemplate = function(filename, cb) {
EmailService.prototype._applyTemplate = function(template, data, cb) { EmailService.prototype._applyTemplate = function(template, data, cb) {
var result = _.mapValues(template, function(t) { var result = _.mapValues(template, function(t) {
try { try {
return t(data); return Mustache.render(t, data);
} catch (e) { } catch (e) {
log.error('Could not apply data to template', e); log.error('Could not apply data to template', e);
return cb(e); return cb(e);

4
lib/templates/new_copayer.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>New copayer {{subjectPrefix}}New copayer
A new copayer just joined your wallet <%= walletName %>. A new copayer just joined your wallet {{walletName}}.

4
lib/templates/new_incoming_tx.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>New payment received {{subjectPrefix}}New payment received
A payment of <%= amount %> has been received into your wallet <%= walletName %>. A payment of {{amount}} has been received into your wallet {{walletName}}.

4
lib/templates/new_outgoing_tx.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>Payment sent {{subjectPrefix}}Payment sent
A Payment of <%= amount %> has been sent from your wallet <%= walletName %>. A Payment of {{amount}} has been sent from your wallet {{walletName}}.

4
lib/templates/new_tx_proposal.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>New payment proposal {{subjectPrefix}}New payment proposal
A new payment proposal has been created in your wallet <%= walletName %> by <%= creatorName %>. A new payment proposal has been created in your wallet {{walletName}} by {{creatorName}}.

4
lib/templates/txp_finally_rejected.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>Payment proposal rejected {{subjectPrefix}}Payment proposal rejected
A payment proposal in your wallet <%= walletName %> has been rejected by <%= creatorName %>. A payment proposal in your wallet {{walletName}} has been rejected by {{creatorName}}.

4
lib/templates/wallet_complete.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>Wallet complete {{subjectPrefix}}Wallet complete
Your wallet <%= walletName %> is complete. Your wallet {{walletName}} is complete.

Loading…
Cancel
Save