4
\$\begingroup\$

I've made a email generator, that uses a HTML template and replaces keywords in the template with information taken from a database. I'm looking to see if there is a way to improve the coding.

public class EmailGenerator : IEmailGenerator
{
    private string mergeTemplate(string template, object obj)
    {
        Regex operationParser = new Regex(@"\$(?:(?<operation>[\w\-\,\.]+)\x20)(?<value>[\w\-\,\.]+)\$", RegexOptions.Compiled);
        Regex valueParser = new Regex(@"\$(?<value>[\w\-\,\.]+)\$", RegexOptions.Compiled);

        var operationMatches = operationParser.Matches(template).Cast<Match>().Reverse().ToList();
        foreach (var match in operationMatches)
        {
            string operation = match.Groups["operation"].Value;
            string value = match.Groups["value"].Value;
            var propertyInfo = obj.GetType().GetProperty(value);

            object dataValue = propertyInfo.GetValue(obj, null);

            if (operation == "endforeach")
            {
                string foreachToken = "$foreach " + value + "$";
                var startIndex = template.LastIndexOf(foreachToken, match.Index);
                var templateBlock = template.Substring(startIndex + foreachToken.Length, match.Index - startIndex - foreachToken.Length);
                var items = (IEnumerable) dataValue;

                string blockResult = "";

                foreach (object item in items)
                {
                    blockResult += this.mergeTemplate(templateBlock, item);
                }

                template = template.Remove(startIndex, match.Index - startIndex + match.Length).Insert(startIndex, blockResult);
            }
        }

        var valueMatches = valueParser.Matches(template).Cast<Match>().Reverse().ToList();
        foreach (var match in valueMatches)
        {
            string value = match.Groups["value"].Value;
            var propertyInfo = obj.GetType().GetProperty(value);

            object dataValue = propertyInfo.GetValue(obj, null);

            template = template.Remove(match.Index, match.Length).Insert(match.Index, dataValue.ToString());
        }

        return template;
    }
}

An idea I have, but haven't been able to implement is to use a while statement instead of the if statement, since the generator needs to start at the end of the template block, so that it replaces the correct information.

Email Template Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/DTD/xhtml1">
<html xmlns="http://www.w3.org/1993/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charste=UTF-8" />
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin: 0; padding: 0;">
<!--[if (gte mso 9)|(IE)]>
<table border="0" cellpadding="0" cellspacing="0" width="600">
    <tr>
        <td>
<![endif]-->
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="padding: 20px 0 30px 0;">
                        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; max-width: 600px;" width="100%">
                            <tr>
                                <td align="center" bgcolor="f7f8f6">
                                    <img src="#" alt="alttext" height="auto" style="display: block;" width="100%" />
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="f7f8f6" style="padding: 20px 30px 40px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 18px;">
                                                <b>ID - $ID$</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 5px 0 0 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">To:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">$Company$</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Referance:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">$Reference$</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Date:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">$Date$</td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; padding: 20px 0 0 0;">We've recieved this information from you:</td>
                                        </tr>
                                        $foreach Items$<tr>
                                            <td style="border-bottom: 1px dashed #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 5px 0 0 0;" width="100%">
                                                <b>$Name$</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 0 0 20px 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Period:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">$Period$</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Update:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><b>$Update$</b></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        $endforeach Items$
                                        <tr>
                                            <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 10px 0 0 0;">
                                                Sincerely,
                                                <br/>
                                                $ContactPerson$
                                                <br/>
                                                <em style="font-size: 11px; line-height: 11px;">For Nordic Trustee (NO)</em>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="13161c" style="padding: 30px 30px 30px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px; line-height: 12px; padding: 10px 0 10px 0;">
                                                Priveleged/confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender for example by reply e-mail.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px;">2019 &copy; Nordic Trustee</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
<!--[if (gte mso 9)|(IE)]>
        </td>
    </tr>
</table>
<![endif]-->
</body>
</html>
\$\endgroup\$
9
  • \$\begingroup\$ Could you add an example of a template too? \$\endgroup\$
    – t3chb0t
    Jun 28, 2019 at 10:05
  • 1
    \$\begingroup\$ @t3chb0t There you go. So the foreach bit will be added multiple times depending on how many rows of information there is in the database list. \$\endgroup\$
    – Akusas
    Jun 28, 2019 at 10:14
  • \$\begingroup\$ You broke the formatting that I've fixed :( \$\endgroup\$
    – t3chb0t
    Jun 28, 2019 at 10:18
  • \$\begingroup\$ @t3chb0t s***, sorry \$\endgroup\$
    – Akusas
    Jun 28, 2019 at 10:23
  • \$\begingroup\$ Have you checked that your recipients actually want HTML in their email? That's an obnoxious thing to inflict on people. \$\endgroup\$ Jun 28, 2019 at 10:23

1 Answer 1

3
\$\begingroup\$

Review

You are re-inventing the wheel here. Building a custom API for transforming templates is very hard to maintain. You have a for each loop now, but soon you'll need much more language constructs. Save yourself the pain and use T4 instead.

  • boiler-plate string-based code constructs are hard to maintain
  • concatenating to a string is bad practice for memory management
  • using regex and string manipulations on one big string is complex and very hard to get right on complex templates

Using T4

1. Setup of T4 in your IDE

  • Install the Tangible T4 Editor Plugin for VS
  • Create a new template from Reusable T4 Template called MailGenerator
  • Two files are created: MailGenerator.tt and MailGenerator.cs. Do not change anything in the cs file. The tt file is used to make the template for the mail generator.

Next steps:

2. Partial class to store template input data

Create a new partial cs file to extend the template. Provide a property DynamicSource of type dynamic to store the input for the mail. By making it dynamic, any input that matches the signature will be compliant to the template.

public partial class MailGenerator
{
    public dynamic DynamicSource { get; set; }
}

3. HTML template in the tt file

Store your HTML code in the tt file and use the T4 language cosntructs to inject the properties from DynamicSource.

Full code:

<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/DTD/xhtml1">
<html xmlns="http://www.w3.org/1993/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charste=UTF-8" />
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin: 0; padding: 0;">
<!--[if (gte mso 9)|(IE)]>
<table border="0" cellpadding="0" cellspacing="0" width="600">
    <tr>
        <td>
<![endif]-->
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="padding: 20px 0 30px 0;">
                        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; max-width: 600px;" width="100%">
                            <tr>
                                <td align="center" bgcolor="f7f8f6">
                                    <img src="#" alt="alttext" height="auto" style="display: block;" width="100%" />
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="f7f8f6" style="padding: 20px 30px 40px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 18px;">
                                                <b>ID - <#= DynamicSource.ID #></b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 5px 0 0 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">To:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><#= DynamicSource.Company #></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Referance:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><#= DynamicSource.Reference #></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Date:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><#= DynamicSource.Date #></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; padding: 20px 0 0 0;">We've recieved this information from you:</td>
                                        </tr>
                                         <# foreach (dynamic item in DynamicSource.Items) { #>
                                        <tr>
                                            <td style="border-bottom: 1px dashed #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 5px 0 0 0;" width="100%">
                                                <b><#= item.Name #></b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 0 0 20px 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Period:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><#= item.Period #></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Update:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><b><#= item.Update #></b></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <# } #>
                                        <tr>
                                            <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 10px 0 0 0;">
                                                Sincerely,
                                                <br/>
                                                <#= DynamicSource.ContactPerson #>
                                                <br/>
                                                <em style="font-size: 11px; line-height: 11px;">For Nordic Trustee (NO)</em>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="13161c" style="padding: 30px 30px 30px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px; line-height: 12px; padding: 10px 0 10px 0;">
                                                Priveleged/confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender for example by reply e-mail.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px;">2019 &copy; Nordic Trustee</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
<!--[if (gte mso 9)|(IE)]>
        </td>
    </tr>
</table>
<![endif]-->
</body>
</html>

As you can see, injection occurs as follows:

  • use <# .. #> to be able to take advantage of C# to manipulate the HTML
  • use <#= item.Name #> to directly output content from your partial class in the HTML
  • possibilities are virtually endless!

code:

    <# foreach (dynamic item in DynamicSource.Items) { #>
    <tr>
        <td style="border-bottom: 1px dashed #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 5px 0 0 0;" width="100%">
            <b><#= item.Name #></b>
        </td>
    </tr>
    <# } #>

4. Generate mail based on runtime input

Now you can tranform any input with correct signature using any template:

[TestMethod]
public void GenerateMail()
{
    dynamic source = new ExpandoObject();
    dynamic item = new ExpandoObject();
    source.ID = 1;
    source.Company = "StackExchange";
    source.Reference = "Some Reference";
    source.Date = DateTime.Now;
    source.ContactPerson = "Akusas";
    source.Items = new List<dynamic>();
    source.Items.Add(item);
    item.Name = "My Name";
    item.Period = DateTime.Now;
    item.Update = "True";

    var template = new MailGenerator { DynamicSource = source };
    var renderedText = template.TransformText();
}

If you have multiple templates, make a tt for each one of them.

5. Verify the output of the transformation

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/DTD/xhtml1">
<html xmlns="http://www.w3.org/1993/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charste=UTF-8" />
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin: 0; padding: 0;">
<!--[if (gte mso 9)|(IE)]>
<table border="0" cellpadding="0" cellspacing="0" width="600">
    <tr>
        <td>
<![endif]-->
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="padding: 20px 0 30px 0;">
                        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; max-width: 600px;" width="100%">
                            <tr>
                                <td align="center" bgcolor="f7f8f6">
                                    <img src="#" alt="alttext" height="auto" style="display: block;" width="100%" />
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="f7f8f6" style="padding: 20px 30px 40px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 18px;">
                                                <b>ID - 1</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 5px 0 0 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">To:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">StackExchange</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Referance:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">Some Reference</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Date:</td>
                                                        <td style="font-size: 0; line-height: 0;" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">06/28/2019 17:06:04</td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="border-bottom: 1px solid #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; padding: 20px 0 0 0;">We've recieved this information from you:</td>
                                        </tr>
                                                                                 <tr>
                                            <td style="border-bottom: 1px dashed #13161c; color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 5px 0 0 0;" width="100%">
                                                <b>My Name</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 0 0 20px 0;">
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Period:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%">06/28/2019 17:06:04</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="25%">Update:</td>
                                                        <td style="font-size: 0; line-height: 0" width="5%"></td>
                                                        <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px;" valign="top" width="70%"><b>True</b></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                                                                <tr>
                                            <td style="color: #13161c; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; padding: 10px 0 0 0;">
                                                Sincerely,
                                                <br/>
                                                Akusas
                                                <br/>
                                                <em style="font-size: 11px; line-height: 11px;">For Nordic Trustee (NO)</em>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="13161c" style="padding: 30px 30px 30px 30px;">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px; line-height: 12px; padding: 10px 0 10px 0;">
                                                Priveleged/confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender for example by reply e-mail.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="color: #f7f8f6; font-family: Helvetica, Arial, sans-serif; font-size: 10px;">2019 &copy; Nordic Trustee</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
<!--[if (gte mso 9)|(IE)]>
        </td>
    </tr>
</table>
<![endif]-->
</body>
</html>
\$\endgroup\$
6
  • 1
    \$\begingroup\$ wow, you are hard working! all this code in such a short time ;-) you could have asked, I have a middleware and a project that do that for-free :-P \$\endgroup\$
    – t3chb0t
    Jun 28, 2019 at 15:26
  • 1
    \$\begingroup\$ It doesn't surprise me anymore you have written anything there is ever to write =D \$\endgroup\$
    – dfhwze
    Jun 28, 2019 at 15:28
  • \$\begingroup\$ but I use t4 too, e.g. for generating nlog configurations by doing sql server reflection ;-] \$\endgroup\$
    – t3chb0t
    Jun 28, 2019 at 15:30
  • 1
    \$\begingroup\$ Big deal, I have written t4 to generate t4 to generate .. :p \$\endgroup\$
    – dfhwze
    Jun 28, 2019 at 15:31
  • 1
    \$\begingroup\$ haha, only if you really really really want to... this question is so old and covered with dust that it might be hard to see what is underneath that protection layer. \$\endgroup\$
    – t3chb0t
    Jun 28, 2019 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.