Skip to content

Instantly share code, notes, and snippets.

Created June 1, 2016 10:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
email template replace vars meteor
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
%val1% %val2%
'email.send': function(filter){
//Do some collection action here to get data based on filter
var data = {
val1: 'Hello',
val2: 'World'
// get content of this file located under /private
var template = Assets.getText('email.template.html');
// search and replace
var result = template.replace(/%(\w*)%/g, function (m, key) {
return data.hasOwnProperty(key) ? data[key] : "";
//email the result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment