I see a lot of people using the Razor viewer for email templates. At first glance, this seems like a great idea. However, after seeing the letters that most people generate, I cannot help but wonder how to use Razor better than just doing a string-based search and replace.
Most emails get line by line:
<html> <head> <title>Welcome to mysite.com</title> </head> <body> <p>Dear @Model.Name,</p> <p>An account has been created for you.</p> <p>Your account is FREE and allows you to perform bla bla features.</p> <p>To login and complete your profile, please go to:</p> <p><a href="@Model.LogOnUrl">@Model.LogOnUrl</a></p> <p>Your User ID is your email address and password is: @Model.Password</p> </body> </html>
In this rather trivial letter, why not just do something like:
string result = template.Replace("@Model.Name", Model.Name);
I suggest that a further search on the Internet may answer this question, but I have not yet found a solid answer. Is this a strictly performance issue? Or simply these simple letters do not demonstrate the real benefits of using the Razor viewer?
My question here has nothing to do with how to implement such a solution, I understand how to do it. My only question is, is it worth the overhead of using Razor when your emails are so simple? Especially if you use RazorEngine, which accepts string inputs and does not lead to any compiled class for the template.
It seems to me that this is too complicated a decision.
source share