Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient plain text template engine

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!

like image 228
captivatedbyUBB Avatar asked Nov 24 '25 03:11

captivatedbyUBB


1 Answers

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!

like image 81
I4V Avatar answered Nov 25 '25 16:11

I4V