lookback / meteor-emails

Improved Meteor emails with templating, previews and automated CSS/SCSS inlining.

Home Page:https://atmospherejs.com/lookback/emails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template not binding too its template data

brent-taft opened this issue · comments

I am integrating your email template package and I am having a issue with databinding. I copied your example email template into my project. If I preview or send using the url - the email template shows up perfectly and the Beatles names are all listed.

However, if i use Mailer.send (see below) - to send the same template. The email shows up - however, the Beatles list is not in the template. I am invoking a server side meteor method using Meteor.call from the client. I can call methods defined in the template like capitalizedName - but binding to data defined in the route.data portion of the template is empty. Any ideas?

if( Meteor.isServer) {

Meteor.methods({

     sendTestMail: function () {

         console.log("sendTestMail entered");

         Mailer.send({
             to: 'xyz@hotmail.com',
             subject: 'My Test',
             template: 'sample',
             data: {
                 //user: 'user1',
                 //team: 'Team1'
             }
         })
     }
});

}

Here is the template:

Templates.sample = {
path: 'sample-email/template.html', // Relative to the 'private' dir.
scss: 'sample-email/style.scss', // Mail specific SCSS.

helpers: {
    capitalizedName : function() {
        //return this.name.charAt(0).toUpperCase() + this.name.slice(1);
        return "testcapname";
    },
    myData : function() {
        return Products.featured();
    }
},
route: {
    path: '/sample/:name',
    data: function(params) {
        return {
            name: params.name,
            names: ['Johan', 'John', 'Paul', 'Ringo'],
            testdata: ["Blah1", "Blah2"],
            test: "this is a test piece of data from the template"
        };
    }
}

};

Thanks for reporting in, gonna have a look at this 🚀

@brent-taft Can you set up a sample app for reproduction of this? I can't reproduce it in the example app in this package.