问题
I have a simple alert system that grabs number on the web, mix them with pre-defined text template to get an alert, and send it to clients. The alert is quite simple plain text, so I would not expect much other than plain text, numbers, simple functions(such as ifthenelse), the quicker the better. So are there any existing open source solutions for this? Thanks!
回答1:
I would use Razor Engine for this.
A templating engine built upon Microsoft's Razor parsing technology. The RazorEngine allows you to use Razor syntax to build robust templates
A simple example from its page:
string template = "Hello @Model.Name! Welcome to Razor!";
string result = Razor.Parse(template, new { Name = "World" });
and result
will be Hello World! Welcome to Razor!
来源:https://stackoverflow.com/questions/16210871/efficient-plain-text-template-engine