Write yourself some helper functions to generate placeholders for your backend language that's actually going to send the email, eg. $('varname') would translate to <?= $varname ?> $.if(..condition..) etc. Load them into global space to save yourself the trouble since you're going to write a lot of components.
You'll also a need a means of outputting raw html (note how placeholders have a lot of unsafe characters; react hates those) Just create a function that given a string as code, outputs <raw dangerouslySetInnerHTML={{_html: code }}/> After you compile the code with React.renderToStaticMarkup strip out any <raw> and </raw> tags from the resulting string and you're in business.
Since you're compiling to your native backend templating system you don't need to worry about keeping a node server going or anything; you just build once and it's done.
Using React (and javascript in general) has some key advantages,
1. you are using components, so you only need to write your garbage table code once and you can use the components to design your emails
2. you can run the same components though multiple configurations; one configuration might generate a template for html emails, another might generate the non-html emails, you just make the components smart in what they output... sadly with the advent of smart watches you're going to have to be sending both, enjoy.
3. you can leverage npm modules; for example the module inline-css will inline css from a css file; so you don't have to do it yourself by hand or rely on copy/pasting back and forth to some site
4. you can run your css though postcss and other compilers for all sorts of backwards compible goodness; including let you know how you've accidentally written such sophisticated code as "background" instead of "background-color" <.<
5. you can pipeline any other junk you have too; push your images to a cdn etc;
6. others, who are not so wise in the table-fu of '99 can dable in creating new emails easily; they just need to use only use existing components and everything (should) be fine most of the time
7. you can share your table-filth with others easily, yey?!
ps.
The biggest headache with emails is not the code involved so much as the time it takes to make the damn things. If you do it with out assistance by hand, what would be a 30min job if built as part of a page, is equivalent in "email dev time" to 1 day easily (don't forget your email client is not the only email client! you have to cater to such wonderful things as Outlook which is under the hood Microsoft Office! of all things). Not the greatest ratio time wise. So no matter how crazy or convoluted the method, I very highly recommend, you do anything in your power to do it any other way then code it 100% by hand.
Write yourself some helper functions to generate placeholders for your backend language that's actually going to send the email, eg. $('varname') would translate to <?= $varname ?> $.if(..condition..) etc. Load them into global space to save yourself the trouble since you're going to write a lot of components.
You'll also a need a means of outputting raw html (note how placeholders have a lot of unsafe characters; react hates those) Just create a function that given a string as code, outputs <raw dangerouslySetInnerHTML={{_html: code }}/> After you compile the code with React.renderToStaticMarkup strip out any <raw> and </raw> tags from the resulting string and you're in business.
Since you're compiling to your native backend templating system you don't need to worry about keeping a node server going or anything; you just build once and it's done.
Using React (and javascript in general) has some key advantages,
1. you are using components, so you only need to write your garbage table code once and you can use the components to design your emails
2. you can run the same components though multiple configurations; one configuration might generate a template for html emails, another might generate the non-html emails, you just make the components smart in what they output... sadly with the advent of smart watches you're going to have to be sending both, enjoy.
3. you can leverage npm modules; for example the module inline-css will inline css from a css file; so you don't have to do it yourself by hand or rely on copy/pasting back and forth to some site
4. you can run your css though postcss and other compilers for all sorts of backwards compible goodness; including let you know how you've accidentally written such sophisticated code as "background" instead of "background-color" <.<
5. you can pipeline any other junk you have too; push your images to a cdn etc;
6. others, who are not so wise in the table-fu of '99 can dable in creating new emails easily; they just need to use only use existing components and everything (should) be fine most of the time
7. you can share your table-filth with others easily, yey?!
ps.
The biggest headache with emails is not the code involved so much as the time it takes to make the damn things. If you do it with out assistance by hand, what would be a 30min job if built as part of a page, is equivalent in "email dev time" to 1 day easily (don't forget your email client is not the only email client! you have to cater to such wonderful things as Outlook which is under the hood Microsoft Office! of all things). Not the greatest ratio time wise. So no matter how crazy or convoluted the method, I very highly recommend, you do anything in your power to do it any other way then code it 100% by hand.