0

This is the butchery I'm dealing with right now on my email.ts file:

fullEmailTemplate(payToName, categoryName, amount) {
return "<!DOCTYPE HTML>\n" +
  "<html>\n" +
  "<head>\n" +
  "\n" +
  "<!-- Responsive Meta Tag -->\n" +
  "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0;\" />\n" +
  "\n" +

So on and so forth.. It's a huge email template that's why I'm not copying everything here.

Problem with that is that lags up my IDE.

How can I have a separate file, like email-template.html and then load it into that function?


Edit: the trick is, since there are many email templates, I'd like to have one html for each template.

How would that work inside a single ts file?

Rosenberg
  • 2,424
  • 5
  • 33
  • 56

2 Answers2

0

You can use instead the new feature of ECMAScript6 (using `)

fullEmailTemplate(payToName, categoryName, amount) {
    return `
        <!DOCTYPE HTML>
            <html>
                <head>
                    <!-- Responsive Meta Tag -->`
Sangarllo
  • 786
  • 6
  • 10
0

Yes you can export your template from another class and import where you need it. Ex:

export class EmailTemplates {
        template1 = `<!DOCTYPE HTML><html><head><!-- Responsive Meta Tag --><!DOCTYPE 
       HTML> 
             <html><head><!-- Responsive Meta Tag -->`;
       };

Import this class and use the template1 from it.EmailTemplates.template1

nircraft
  • 8,242
  • 5
  • 30
  • 46
  • Also take a look here for more : https://stackoverflow.com/questions/47712892/import-html-template-in-typescript – nircraft Dec 06 '18 at 20:04