node.js - MeteorJS: Generating emails from templates server-side -


i need send emails meteorjs application , want generate them using html templates, not "html-in-js" stuff.
i've tried do:
1) use template.emailtemplate(data), template not defined server-side.
2) save email templates *.html files under <app>/server/email/templates directory, contents using fs.readsync() , compile/render using meteor's built-in handlebars package.
works fine in development environment, fails in production using bundled app because of *.html files under server directory not bundled. besides, structure of directories changed during bundle process , relative paths templates become invalid.
3) proposals? =)

currently, templates not supported server-side. functionality coming. in mean time, created package might find useful called handlebars-server allows use handlebars on server. can use package atmosphere or copying project directory packages folder. here example:

example:

my-email.handlebars

hello, {{name}} 

server.js

email.send({   html: handlebars.templates['my-email']({ name: 'chris' }) }); 

note

no templates in handlebars file. put html , handlebars expressions. file compiled function , assigned property on handlebars.templates object. property name name of file minus handlebars extension.

github

https://github.com/eventedmind/meteor-handlebars-server


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -