You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can see that RazorEngine are a moving target. Don't know if you have been working with version 3.1
I have started to write some code but I am not sure on how to cache the template.
private static void ConfigureRazorEngineEmailSettings(IAppBuilder app, Container container, AppSettingsRepository settings)
{
var templateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplates");
var config = new TemplateServiceConfiguration();
config.Namespaces.Add("Goo.Web.Api.Models");
var service = RazorEngineService.Create(config);
var html = File.ReadAllText(Path.Combine(templateFolderPath, "SuggestNewWord.cshtml"));
var htmlSuggestNewWord = PreMailer.Net.PreMailer.MoveCssInline(html);
// do we need this
service.AddTemplate("SuggestNewWord", htmlSuggestNewWord.Html);
var emailBody = service.RunCompile("SuggestNewWord", typeof(AboutPosFormModel));
// run this code in a API controller
emailBody = service.Run("SuggestNewWord", typeof(AboutPosFormModel), new AboutPosFormModel());
}
There are RunCompile and Run. I guess that I use RunCompile in the setup and Run in my controllers.
Then there are service.AddTemplate this is a little confusing because RunCompile with a key should cache the template.
You are singing the praise of Premailer.Net but not using it.
Where in the rendering flow should I use PreMailer?
The text was updated successfully, but these errors were encountered: