I'm a beginner in Meteor and i would like to send an invitation link to a dynamic generated page in my app with iron:router.
Meteor.methods({
'sendEmail': function(to) {
this.unblock();
SSR.compileTemplate( 'emailText', Assets.getText( 'html-email.html' ) );
Template.emailText.helpers({
link: function () {
return Router.current().route.path(this);;
}
});
Email.send({
to:to,
from: 'no-reply@whatever.xyz',
subject:'xyz wants to invite you ',
html: SSR.render('emailText')
});
}})
}
The Problem is that i dont get the url of the site in my html-email.html
. There i got
<a href="{{link}}">Link to invitation</a>
What am i doing wrong?
Your method is a server method (SSR). Router.current()
is a client method and cannot return anything server side. The solution is to pass the url as a parameter. Call your method that way :
Meteor.call( 'sendEmail', email, url, ... )
Then your method will be :
'sendEmail': function( to, url ) {...